Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top