I'm trying to automate the actual geo-referencing in PyQgis/PyQt5. I went manually over the built-in GDAL Georeferencer in QGIS and saved a GCP-file. Also, the actual commands used for the conversion are available:

gdal_translate -of GTiff <gcpString> <inputFile> <tempFile>
gdalwarp -r cubic -order 2 -co COMPRESS=NONE <tempFile> <outputFile>

I tried to 'copy' this behaviour in PyQt5 using subprocess.Popen() but it seems from PyQgis I do not have permissions or access to the gdal cmd-tools.

Then, I stumbled upon the Python GDAL library which is (I think) built-in with QGIS, and seems a good option. However, I cannot get this to work with the given options as above and documentation is not very easy.
What would be the best approach for referencing the image with a given GCP-file and options?

  • Side note: write <tempfile> as a virtual file by using -of VRT. VRT is a short XML file and much faster to write than the physical GeoTIFF image. – user30184 May 15 '19 at 14:31
  • <tempFile> is just there because the generated script from the referencer-plugin uses one. I actually don't need it, and I'm only interested in the fully referenced and reprojected geoTiff <outputFile> – user142643 May 15 '19 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy