Search code examples
gispostgisgeodjango

Point storage format: lat/lon or lon/lat?


First time user of PostGIS here.

I've been inserting my POINT fields in the conventional lat/lon order for a while now but it seems like when I explore PostGIS, it launches a map and it appears that the coordinates are read in lon/lat format, meaning everything is off from what I initially thought. I notice this is the case in Django admin as well for PointField.

Does PostGIS enforce a particular order or is the order up to me? Are there any repercussions from storing them as lat/lon, e.g. will distance calculations be off?


Solution

  • PostGIS's ST_MakePoint expects (x, y) order, which corresponds to (longitude, latitude) order. Storing it in reverse order would simply be incorrect.

    There's some good reading here: https://macwright.org/lonlat/

    I personally advocate for lon/lat order in general, since that is equivalent to the mathematical x/y convention. But in any case, you must always verify with the software you are using; you don't get to pick.