Skip to main content
Solved

Python sample script for accessing local GDAL library

  • July 14, 2022
  • 2 replies
  • 166 views

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • 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
  • 60 replies
  • July 22, 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

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