4

I use to manually georeferencing rasters using the plugin GDAL using:

  • raster .tif
  • 4 gcps in a file .point

enter image description here

and it results this :

enter image description here

My aim is to batch this method for thousand of rasters (drone pictures) using projective transformation, in PyQGIS but I noticed this function is not available in the graphical modeller.

In a source folder I have several (thousand) pictures. For each picture, there is a file "point" : which have the same name (just the extension changes: .jpg for picture and .point for points) : picture1.jpg ; picture1.point ; picture2.jpg ; picture2.point; etc.

For every picture in this folder, I would like to loop this kind of approach :

gcp_points = picture1.point
gdal.gdal_translate(picture1.jpg, gcp_points, out_raster1, 'projective')

the source code of the plugin GDAL is : https://github.com/qgis/QGIS/blob/32c2cea54cb92bbb2243b222816c8154c2b9adf9/src/analysis/georeferencing/qgsgcptransformer.cpp

How do I reproduce the processing shown in the screenshot using PyQGIS?

zlikotp
  • 24
  • 2
  • 19
  • Have you seen this one : https://gis.stackexchange.com/a/116872/93097 – J. Monticolo Oct 28 '21 at 15:45
  • 1
    Yes I saw it, but the transformation I need is projective and in this post he doesn't do this transoformation – zlikotp Oct 29 '21 at 07:35
  • And maybe the Open Drone Map toolkit : https://www.opendronemap.org/odm/ ? – J. Monticolo Oct 29 '21 at 08:31
  • 1
    If your images include pictures of the ground control points, and you know the locations of the ground control points, you would also need the know the pixel coordinates of the GCP in the images to automate georeferencing. How do you get those image pixel coordinates? You can provide me with some test images and I can try using these tools https://www.linkedin.com/posts/gerry-gabrisch-gisp-2aa3263b_algorithm-based-automated-georeferencing-activity-6910658166561153024-M1gy?utm_source=share&utm_medium=member_desktop – GBG Oct 17 '22 at 21:22
  • for each image there is a "point file" who have the same name of the image. I'm going to edit my initial post – zlikotp Oct 18 '22 at 08:33
  • sorry, the image pixel coordinates are the 4 corners of the images – zlikotp Oct 18 '22 at 11:06
  • 1
    This is interesting. GDAL does not support projective transformation so QGIS must have a native solution for that. I have no idea how to call the native methods from Python. The source code is here https://github.com/qgis/QGIS/blob/32c2cea54cb92bbb2243b222816c8154c2b9adf9/src/analysis/georeferencing/qgsgcptransformer.cpp – user30184 Oct 19 '22 at 11:54
  • @user30184 thanks you so much, this is a very very usefull information ! I also have no idea how to adapt this in python. I'm going to edit my post with this link ! – zlikotp Oct 19 '22 at 22:14
  • 1
    If you want to automate image reprojection with pyqgis you won't be able to do it unless you do a custom version of qgis with the binding exposed. The reprojection method that is exposed seem to have been done for vector reprojection. Otherwise the easiest option is gdal without projection or use something like autohokey to automate the data input in the georeferencer instead of doing it manually. – Al rl Oct 21 '22 at 23:49
  • I've edited my original post, yes I have to automate the data input: in a folder, there are pictures. For each picture, there is a file "point" : which have the same name (just the extension changes: .jpg for picture and .point for points). – zlikotp Oct 22 '22 at 01:10
  • but about the loop, I think it is not the hardest part of my need. Once I will be able to have the function who can do this programmaticly, I will be able to automate it easly. What I need is to be able to georeference a picture file with a gcps files which contain local (picture) and scr coordinates. – zlikotp Oct 22 '22 at 01:19

0 Answers0