2

I have a wrong displaying of my PointFields in the admin interface of GeoDjango.

Here is my model:

models.py

1 class FOO(models.Model):
2     name = models.CharField(max_length=100)
3     point = models.PointField(srid=4326)
5     objects = models.GeoManager()

But when I create a point like :

from django.contrib.gis.geos import Point
p = Point(43.620416,7.065491)
foo = FOO(.. , point=p)
foo.save()

It is not in the database in a correct format, in this example it is like (4856153.76879, 788079.64711) on the display with OSM, that is to say something completely different than what I entered. Does anyone have an idea to explain this behaviour?

Thanks in advance

1 Answer 1

2

My guess is that you switched the latitude and the longitude. Looking at the coordinates you gave, I assume that you wanted the latitude to be 43.620416, and the longitude to be 7.065491, so that the point would be in France. However, according to the doc, GeoDjango expects the first value to be the longitude, and the second one the latitude.

Switching these two coordinates may have caused GeoDjqngo to get lost with the values you gave. (4856153.76879, 788079.64711) may then be some internal representation of the point you gave.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.