[gdal-dev] Is it possible to test if GDAL has been built with GEOS in a python script

Even Rouault even.rouault at mines-paris.org
Tue Mar 8 16:21:01 EST 2011


Le mardi 08 mars 2011 22:03:41, Dan Putler a écrit :
> Hi all,
> 
> As the message heading indicates, I am hoping to run a check within a
> python script to determine if GDAL on a machine has been built with GEOS
> support, and exit if it hasn't. Looking at inspect.getmembers( gdal )
> suggests that I'm out of luck, but I wanted to confirm this.

Look at the have_geos() method at the end of 
http://trac.osgeo.org/gdal/browser/trunk/autotest/pymod/ogrtest.py

This is how the GDAL autotest suite detects if it must run the GEOS related 
tests. This is a bit of indirect way of detecting it, but if you have no GEOS 
support, the Union() method will return None. You may want to silent the error 
emitted by surrounding the call to Union() with 

gdal.PushErrorHandler('CPLQuietErrorHandler')
gdal.PopErrorHandler()

> 
> Dan
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list