Solved

Python sample script for accessing local GDAL library


Badge +1

Hi,

 

Are GDAL raster processing tools available in QGIS also accessible from FME Desktop on the same machine? If yes, does someone have an example script of how to call and run such a tool from the GDAL library. In QGIS I would for instance use the tool itself with the following command line for generating contour polygons:

gdal_contour -b 1 -p -amin minimum -amax maximum -i 50.0 -snodata -999999994.0 -f "ESRI Shapefile" <input path> <output path>

How would the code need to look like for example in a PythonCaller on a typical Windows machine with both FMEDesktop and QGIS installed on it?

 

Thank you!

 

Best regards,

 

Olivier

 

 

 

icon

Best answer by debbiatsafe 19 July 2022, 02:10

View original

2 replies

Userlevel 3
Badge +17

Hello @olivier​ ,

As you already have a working command line, it should be possible to use the SystemCaller to execute the command. All you have to do is specify the full path to gdal_contour if its parent directory isn't listed in the PATH environment variable.

 

In case you still want to Python, then I would recommend taking a look at this very helpful post about using GDAL, Python, and rasters https://community.safe.com/s/question/0D54Q00009OG1H8SAL/python-fme-api-working-with-rasters-and-gdal

Badge +1

Hello @olivier​ ,

As you already have a working command line, it should be possible to use the SystemCaller to execute the command. All you have to do is specify the full path to gdal_contour if its parent directory isn't listed in the PATH environment variable.

 

In case you still want to Python, then I would recommend taking a look at this very helpful post about using GDAL, Python, and rasters https://community.safe.com/s/question/0D54Q00009OG1H8SAL/python-fme-api-working-with-rasters-and-gdal

Hi @debbiatsafe​ ,

Thank you very much! I had indeed forgotten about the SystemCaller. This sounds like the best approach in this context. I am now out of the office but will give it a try as soon as I can.

All the best,

Olivier

Reply