[Qgis-developer] Python plugin - Path to gdal

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Nov 10 09:38:26 EST 2010


On Wed, Nov 10, 2010 at 2:04 PM, kimaidou <kimaidou at gmail.com> wrote:

> I have no idea how I can find the path of the gdal binary used by Qgis. Of
> course I need an OS independant method.
>
> I tried to read the GdalTool plugin code, but woow, it is a bit too
> complicated for me rigth now. E.g, I have seen there is a function :
>
> # Retrieves GDAL binaries location
> def getGdalPath():
>   settings = QSettings()
>   return settings.value( "/GdalTools/gdalPath", QVariant( "" ) ).toString()
>
> But I am not sure it will work if run from another plugin (especially if
> GdalTool is not installed/active ).

 That's about right. GdalTools has a preferences dialog (in the
Raster... GdalTools Settings option) that lets you specify a path to
the gdal executables. I'm guessing that if the GdalTools guys couldnt
find a better way, then you won't either :)

 I would suggest you try getting the same setting from QSettings, and
if that doesn't exist you'll need to get it from the user and store it
yourself in a QSettings parameter for your plugin. Actually I think if
the command is in your PATH then QProcess should find it without you
having to specify it.

Barry


More information about the Qgis-developer mailing list