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_id=78
[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-PartyLibraryInstallationTests
[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/errcheck.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".
The example works perfectly now. Thanks very much!
> There have been some significant changes to GeoDjango since FOSS4G
> (e.g., GEOS & GDAL refactors, distance queries, additional spatial
> backends). However, substantively, everything should still work as
> shown. This particular bug is an artifact of the GDAL library
> refactoring: the census shapefiles do not explicitly give a spatial
> reference, which is NAD83, and the `srs` property should be None
> instead of raising an exception. One thing that has explicitly
> changed is that `models.GeoMixin` is no longer required for geographic
> models.
I appreciate your taking the time to explain the issue. It's very
helpful for someone just starting out with GeoDjango.
Thanks,
Joe