Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

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..

share|improve this answer
    
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
1  
@gridcell You might want to post the bug/issue as an answer and accept it. –  Chad Cooper Dec 29 '12 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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