[Qgis-developer] Proper way to get the path to gdal's executables from a python plugin

Olivier Dalang olivier.dalang at gmail.com
Fri Apr 29 17:19:45 PDT 2016


Dear List,

I'm updating the RasterBender plugin and need to use the gdalwarp and
gdal_translate command line tools from within Python. What is the
recommended way to run gdal command line tools from within a QGIS plugin ?

Here under Windows it works with :

subprocess.check_call(''C:\\OSGeo4W\\bin\\gdalwarp...

But obviously that won't work on other setups.

Surprisingly it works too with :

subprocess.check_call('gdalwarp...

Will this work on all setups ? I have no Mac to test on, and am not
completely aware of the differences between standalone installs and osgeo4w
installs..

I looked into the GdalTools plugin and the Processing plugin, but their
method to get the GdalTool seems excessively complex (the rely on some user
settings which don't seem to be set here, and/or do some voodoo about
environment variables which I don't really understand...).


Thanks !

Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160430/d0f8fed1/attachment.html>


More information about the Qgis-developer mailing list