I'm following along with the GeoDjango_Presentation.pdf at [1] from
the FOSS4G 2007 presentation at [2], using the shapefile
'st99_d00.shp' from [3]. When trying the example code listed on the
bottom slide of page 11 in the pdf , I get an error:
SRSException: Invalid spatial reference pointer returned from
"OGR_L_GetSpatialRef".
This occurs on both Debian Etch and OS X 10.4 (both are using GDAL
version 1.4.2 and python 2.4 with ctypes package installed). I'm just
starting out with GeoDjango so I'm not sure if it's an installation
problem or the code. I was able to successfully run the third-party
library installation tests at [4] and also the DataSource example at
[5], in case that helps to shed any light on the soundness of my
installation.
Should the example still work with the latest svn revision of
GeoDjango? The IPython session is pasted below.
Thanks,
Joe
[1] http://www.foss4g2007.org/presentations/viewattachment.php?attachment...
[2] http://www.foss4g2007.org/presentations/view.php?abstract_id=222
[3] http://www.census.gov/geo/cob/bdy/st/st00shp/st99_d00_shp.zip
[4] http://code.djangoproject.com/wiki/GeoDjangoInstall#Third-PartyLibrar...
[5] http://code.djangoproject.com/wiki/GeoDjangoExtras#DataSource
This IPython session is also pasted at http://dpaste.com/hold/27869/ :
==========================================================================
In [1]: from django.contrib.gis.utils import ogrinfo
In [2]: ogrinfo('st99_d00.shp',num_features=1)
data source : st99_d00.shp
==== layer 0
shape type: Polygon
# features: 273
---------------------------------------------------------------------------
django.contrib.gis.gdal.error.SRSException
Traceback (most recent call last)
/home/joe/foss4g/<ipython console>
/usr/lib/python2.4/site-packages/django/contrib/gis/utils/ogrinfo.py
in ogrinfo(data_source, num_features)
27 print " shape type: %s" %
GEO_CLASSES[layer.geom_type.num].__name__
28 print " # features: %s" % len(layer)
---> 29 print " srs: %s" % layer.srs
30 extent_tup = layer.extent.tuple
31 print " extent: %s - %s" % (extent_tup[0:2],
extent_tup[2:4])
/usr/lib/python2.4/site-packages/django/contrib/gis/gdal/layer.py in srs(self)
100 def srs(self):
101 "Returns the Spatial Reference used in this Layer."
--> 102 ptr = get_layer_srs(self._ptr)
103 if ptr:
104 return SpatialReference(clone_srs(ptr))
/usr/lib/python2.4/site-packages/django/contrib/gis/gdal/prototypes/errchec k.py
in check_srs(result, func, cargs)
89 result = c_void_p(result)
90 if not result:
---> 91 raise SRSException('Invalid spatial reference pointer
returned from "%s".' % func.__name__)
92 return result
93
SRSException: Invalid spatial reference pointer returned from
"OGR_L_GetSpatialRef".