[gdal-dev] gdal Python bindings and postgis question
niels hoffmann
nielslcr at gmail.com
Tue Feb 26 23:04:13 EST 2008
Hi list,
I am trying to get the python bindings to gdal to work on windows and Python
2.5.1 to connect to Postgis. I know everything is packaged in FWTools, and I
have it working that way. But I want to use the shapely package, which
requires python 2.4+
So I extracted the gdalwin32exe150.zip and added the bin dir of it to my
path and created the GDAL_DATA env variable.
I downloaded the ogr_PG.dll and added it to the bin\gdalplugins dir. The
path to the pg_config.exe is also in my path variable (not sure if that is
important)
I grabbed the GDAL-1.5.0.win32-py2.5.exe from
http://pypi.python.org/pypi/GDAL and installed that.
If I open a shapefile that is ok, but if I try to open my Postgis dataset I
get a NoneType error back:
>>> from osgeo import ogr
>>> dir(ogr)
['CreateGeometryFromGML', 'CreateGeometryFromJson', 'CreateGeometryFromWkb',
'CreateGeometryFromWkt', 'DataSource', 'DataSource_swigregister',
'DontUseExceptions', 'Driver', 'Driver_swigregister', 'Feature',
'FeatureDefn', 'FeatureDefn_swigregister', 'Feature_swigregister',
'FieldDefn', 'FieldDefn_swigregister', 'Geometry', 'Geometry_swigregister',
'GetDriver', 'GetDriverByName', 'GetDriverCount', 'GetOpenDS',
'GetOpenDSCount', 'Layer', 'Layer_swigregister', 'ODrCCreateDataSource',
'ODrCDeleteDataSource', 'ODsCCreateLayer', 'ODsCDeleteLayer', 'OFTBinary',
'OFTDate', 'OFTDateTime', 'OFTInteger', 'OFTIntegerList', 'OFTReal',
'OFTRealList', 'OFTString', 'OFTStringList', 'OFTTime', 'OFTWideString',
'OFTWideStringList', 'OJLeft', 'OJRight', 'OJUndefined', 'OLCCreateField',
'OLCDeleteFeature', 'OLCFastFeatureCount', 'OLCFastGetExtent',
'OLCFastSetNextByIndex', 'OLCFastSpatialFilter', 'OLCRandomRead',
'OLCRandomWrite', 'OLCSequentialWrite', 'OLCTransactions', 'Open',
'OpenShared', 'RegisterAll', 'SetGenerate_DB2_V72_BYTE_ORDER',
'UseExceptions', '__builtins__', '__doc__', '__file__', '__name__',
'_newclass', '_object', '_ogr', '_swig_getattr', '_swig_property',
'_swig_repr', '_swig_setattr', '_swig_setattr_nondynamic', 'new',
'new_instancemethod', 'osr', 'wkb25Bit', 'wkbGeometryCollection',
'wkbGeometryCollection25D', 'wkbLineString', 'wkbLineString25D',
'wkbLinearRing', 'wkbMultiLineString', 'wkbMultiLineString25D',
'wkbMultiPoint', 'wkbMultiPoint25D', 'wkbMultiPolygon',
'wkbMultiPolygon25D', 'wkbNDR', 'wkbNone', 'wkbPoint', 'wkbPoint25D',
'wkbPolygon', 'wkbPolygon25D', 'wkbUnknown', 'wkbXDR']
>>> ogr.RegisterAll()
>>> ds = ogr.Open('PG:dbname=postgis host=localhost', update = 1 )
>>> print ds.GetLayerCount()
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'GetLayerCount'
>>> ds = ogr.Open
(r'C:\arcgis\ArcTutor\ArcScan\ExerciseData\ParcelLines.shp')
>>> print ds.GetLayerCount()
1
Does anybody know what I am missing?
Regards,
Niels Hoffmann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080227/e1530611/attachment.html
More information about the gdal-dev
mailing list