I have been importing polygon data on PostGIS but started to wonder if I had input latitude/longitude in the right order. On PostGIS doc there is a page https://postgis.net/2013/08/18/tip_lon_lat/ that clearly states spatial database records longitude as x and latitude as y, which after reflection does make sense. It's also written on https://postgis.net/docs/ST_MakePoint.html "For geodetic coordinates, X is longitude and Y is latitude".

My confusion comes from the fact that I did import data with latitude/longitude as x/y. For example:

Text: POINT(36.060409 -79.816702)
X: 36.060409
Y: -79.816702

a point near Greensboro in the US.

So according to PostGIS, X is longitude and Y is latitude, but if I plot this it gives me a point in Antarctica. If I plot on Google map, as is (.i.e 36.060409, -79.816702), which does get coordinates as latitude,longitude, then the location is correct.

I am confused about how PostGIS records the data and how am I supposed to input it?

I use PostgreSQL 12, PostGIS 3.1.0 and SRID 4326

  • 1
    In geographic coordinates X = 36 Y = -79 is very close to Antarctica, grab a globe and have a look. I would suggest your point should be POINT(-79.816702 36.060409) X: -79.816702 Y: 36.060409 as you're west of Greenwich and north of The Equator. This happens a lot when you import LAT/LON from CSV using the first value as X and the 2nd as Y where it should be first value Y and 2nd value X. – Michael Stimson Feb 3 at 5:31
  • My point is that when I plot lat: 36.060409, long:-79.816702 it gives me the right point on earth. Try plotting X: -79.816702 Y: 36.060409 and gives a point in Antarctica. – Sylvain Feb 3 at 10:30
  • I don't have points at hand, but see a POLYGON in Austria that was retrieved using ST_AsText: POLYGON((14.2940925198263 47.8925784983472,[...])). Clearly X is longitude and Y is latitude. – Stefan Feb 3 at 12:17

Your Answer

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

Browse other questions tagged or ask your own question.