I'm a total beginner with PostGIS, and trying to create a database with the geonames dataset.

Their table has latitude and longtitude coordinates:

latitude : latitude in decimal degrees (wgs84)
longitude : longitude in decimal degrees (wgs84)

Since the data is global and in WGS84, I've used the type: geography(point,4326), and inserted it using ST_MakePoint(lat, long).

However, I get a lot of warnings: NOTICE: Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY

Did I use the wrong type?

  • 3
    You likely failed to use the longitude value before the latitude in the constructor (in {x,y} order, as required), but you've left that key detail out of this question. Please also edit to specify the exact software in use. – Vince Feb 13 '17 at 19:22
  • Thanks! That was the issue. Please post your comment as an answer, and I'll be happy to accept. – dimid Feb 13 '17 at 19:28
  • Please edit the question to capture the actual procedure, so than an answer long enough to be worthwhile could be written. – Vince Feb 13 '17 at 22:09

(This is the #1 mistake that everyone learning PostGIS makes at least once, so don't feel silly)

The axis order for all coordinate data in PostGIS is (X Y) or (long lat).

Therefore the correct geometry constructor is ST_MakePoint(long, lat).

You can also use ST_FlipCoordinates to repair geometry/geography columns.

Your Answer

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

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