Skip to main content
Solved

Python sample script for accessing local GDAL library


olivier
Contributor
Forum|alt.badge.img+7

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

 

 

 

Best answer by debbiatsafe

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

View original
Did this help you find an answer to your question?

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • Best Answer
  • July 19, 2022

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


olivier
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • July 22, 2022
debbiatsafe wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings