3

I'm running into a problem when saving a coordinate into one of my models in (Geo)Django. My point field is setup as:

location = PointField(blank=True, null = True)

So while running some tests in the django shell I noticed my coordinates were changing...

obj.location = 'POINT(-120.18444970926208 50.65664762026928)'
obj.save()
print(obj.location.x)

-120.1840742

print(obj.location.y)

50.6569673

Another thing I've noticed If I set the point using an UPDATE in postgres and then...

print(obj.location.y)

50.65664762026928

but if I run a save and check the coordinate again I get...

obj.save()
print(obj.location.y)

50.6569673

Anybody have any ideas where I can start looking to sort this out or any suggestions what may be causing this.

Thanks, Dustin

Software:

  • Django 1.3.1
  • GDAL 1.9.1
  • Python 2.7.2
  • PostGIS 1.5.3
  • GEOS 3.3.3
  • PostgreSQL 9.1.4
2

try to add your srid to your point for a more detailed explanation.

>>> from django.contrib.gis.geos import GEOSGeometry
>>> point_loc = GEOSGeometry('POINT(-120.18444970926208 50.65664762026928)', srid=3084)  
>>> z = Object(location = point_loc)
>>> z.save()

i hope it helps you..

  • I've defined the SRID before using 'SRID=4326;POINT(-120.18444970926208 50.65664762026928)' and I also just tried your method with no luck. – gridcell Aug 1 '12 at 12:20
  • Tracked it down to a bug somewhere else. Thanks Aragon for the feedback. – gridcell Aug 1 '12 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.