Opened 8 years ago

Closed 10 months ago

#9295 closed New feature (wontfix)

Better error handling and/or error reporting when Proj.4 datum shifting files are not found

Reported by: springmeyer Owned by: jbronn
Component: GIS Version: 1.0
Severity: Normal Keywords: proj4, datum shifing, geodjango-basic-apps, postgis, 900913, projections
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


A very common install problem for new users to GeoDjango is to use a package management system for installing proj which does not include the Proj.4 datum shifting files (A key question is do any packager of proj include these files?). Or a user does a source install of proj and misses the instructions here: and fails to manually install the additional files.

The impact of the lacking files is often first seen for new users who download one of the apps that uses the OSMGeoAdmin from Without a use of GeoDjango like this that does transformations between Google Spherical Mercator projection ( and another projection in a different datum, this installation problem might not surface for many users.

OSMGeoAdmin uses GDAL to do reprojection of data into SRID 900913 for the Admin OpenLayers map and then uses the spatial database backend to reproject the data back to the native SRID after the save() method is called.

With a PostGIS backend the spatial data is sent to in the database without proper reprojection due to the missing files with no error warning of the missing files needed. The geometry therefore misses the validation check at the form level, such that and error is throw by a GEOS error check only after finding corrupt coordinates which is not super intuitive as to the original problem:

Error encountered checking Geometry returned from GEOS C function "GEOSGeomFromHEX_buf"

Attachments (1)

geoadminsite.diff (1.9 KB) - added by jbronn 8 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 8 years ago by springmeyer

For the sake of google indexing, here's the whole error which I could prompt by moving the folder '/usr/local/share/proj' to a new spot on the filesystem such that postgis can no longer find it.

This error happens on page reload of a previously saved record in the admin. Again, this is not a GeoDjango problem but I do think GeoDjango could provide better error handling and reporting.


Request Method: GET
Request URL: http://localhost:8000/admin/world/worldborders/2/
Django Version: 1.1 pre-alpha SVN-9109
Python Version: 2.5.1
Installed Applications:
Installed Middleware:

File "/Users/spring/src/django-svn-trunk/django/core/handlers/" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/" in root
  157.                 return self.model_page(request, *url.split('/', 2))
File "/Users/spring/src/django-svn-trunk/django/views/decorators/" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/" in model_page
  176.         return admin_obj(request, rest_of_url)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/" in __call__
  197.             return self.change_view(request, unquote(url))
File "/Users/spring/src/django-svn-trunk/django/db/" in _commit_on_success
  238.                 res = func(*args, **kw)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/" in change_view
  589.             form = ModelForm(instance=obj)
File "/Users/spring/src/django-svn-trunk/django/forms/" in __init__
  201.             object_data = model_to_dict(instance, opts.fields, opts.exclude)
File "/Users/spring/src/django-svn-trunk/django/forms/" in model_to_dict
  123.             data[] = f.value_from_object(instance)
File "/Users/spring/src/django-svn-trunk/django/db/models/fields/" in value_from_object
  332.         return getattr(obj, self.attname)
File "/Users/spring/src/django-svn-trunk/django/contrib/gis/db/models/" in __get__
  36.             geom = self._klass(geom_value)
File "/Users/spring/src/django-svn-trunk/django/contrib/gis/geos/" in __init__
  66.                 g = from_hex(geo_input, len(geo_input))
File "/Users/spring/src/django-svn-trunk/django/contrib/gis/geos/prototypes/" in check_geom
  32.         raise GEOSException('Error encountered checking Geometry returned from GEOS C function "%s".' % func.__name__)

Exception Type: GEOSException at /admin/world/worldborders/2/
Exception Value: Error encountered checking Geometry returned from GEOS C function "GEOSGeomFromHEX_buf".

comment:2 Changed 8 years ago by jbronn

Owner: changed from nobody to jbronn

comment:3 Changed 8 years ago by jbronn

Attached is a patch which will bring back GeoAdminSite and override check_dependencies so that GeoDjango may raise an informative exception -- this still needs to be implemented. Moreover, I think I've figured out a way around the registration problem by also overriding autodiscover so that GeoDjango's site instance may also have 'normal' Django site registrations.

Changed 8 years ago by jbronn

Attachment: geoadminsite.diff added

comment:4 Changed 8 years ago by springmeyer

Cool jbronn.

As background, here's some context on the lack of inclusion of the files in the debian packages:

comment:5 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:6 Changed 8 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:7 Changed 8 years ago by springmeyer

A reference for folks working around this error, here is a workaround for the lack of packaging of the datum files that maintains to use of debian packages:

Thanks rcoup!

# note the lack of a complete set of proj files...
$ ls /usr/share/proj/
epsg  esri.extra  nad27  nad.lst      proj_def.dat
esri  GL27	  nad83  other.extra  world

# re build the proj pkg after manually download the data files..
apt-get install fakeroot build-essential debhelper
cd ~/src
apt-get source proj
cd proj-4.6.0/nad/
tar xzf ../../proj-datumgrid-1.4.tar.gz
cd ../
dpkg-buildpackage -rfakeroot -b
cd ../
dpkg -i proj_4.6.0-2_i386.deb

$ ls /usr/share/proj/
alaska	epsg  esri.extra  GL27	  MD	 nad83	  ntf_r93.gsb	null		    other.extra   prvi	    stlrnc  TN	WO
conus	esri  FL	  hawaii  nad27  nad.lst  ntv1_can.dat	nzgd2kgrid0005.gsb  proj_def.dat  stgeorge  stpaul  WI	world

comment:8 Changed 6 years ago by Luke Plant

Severity: Normal
Type: New feature

comment:9 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:10 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:11 Changed 10 months ago by Claude Paroz

Resolution: wontfix
Status: newclosed

I'm not sure this is still a problem nowadays, considering the lack of interest/activity in this ticket.

Note: See TracTickets for help on using tickets.
Back to Top