[GIS] Python Gdal ERROR 6: GEOS support not enabled

gdalgeospython

I installed GDAL from here (https://pypi.python.org/pypi/GDAL/1.9.1)

Before attempting the python GDAL I installed the prerequisite gdal libraries using Kyngchaos's description some time ago (http://www.kyngchaos.com/software/frameworks). I have verified that gdal is running on at least the minimum required version:

gdalinfo --version
GDAL 1.11.1, released 2014/09/24

However, when I attempt to start python and access the gdal libraries I get errors on simple operations:

from osgeo import ogr
point = """{"type":"Point","coordinates":[-90.02001032734194,35.127405562848075]}"""
geom = ogr.CreateGeometryFromJson(point)
geom.Centroid()
ERROR 6: GEOS support not enabled.
<osgeo.ogr.Geometry; proxy of <Swig Object of type 'OGRGeometryShadow *' at 0x10344d9f0> >

I have googled this error and looked at how it has been mentioned on this site but no solutions seem to pertain to my situation. The Kyngchaos GDAL/OGR installs are built with GEOS libraries, so I'm very confused as to why python GDAL/OGR is saying GEOS is not enabled.

Any ideas on how I can fix or go about debugging this (running on Mac OSX)?

Edit 1:

I have verified that gdal 1.11.1 is being loaded with osgeo by forcing this specific version to top of path.

import sys
oldpaths = sys.path
sys.path = ['/Library/Frameworks/GDAL.framework/Versions/1.11/Python']
sys.path.extend(oldpaths)

from osgeo import gdal
print gdal.__version__
1.11.1

however I still get ERROR 6: GEOS support not enabled. on trying to take the centroid of a geom

Best Answer

I was able to successfully solve my problem by ensuring that the correct path to GDAL/GEOS was given. If GDAL/goes was installed via KyngChaos's method, you can add the correctly configured gdal to the path manually:

import sys
oldpaths = sys.path
sys.path = ['/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages']
sys.path.extend(oldpaths)

from osgeo import ogr
point = """{"type":"Point","coordinates":[-90.02001032734194,35.127405562848075]}"""
geom = ogr.CreateGeometryFromJson(point)
print geom.Centroid()
POINT (-90.020010327341936 35.127405562848075)

With the correct GDAL version path, I no longer get the error.