0

I am attempting to store a LINESTRING using PostGIS into a column of type geography(LINESTRING, 4326). Here is my insert statement:

INSERT into routes (line) VALUES (st_linefromtext('LINESTRING(-35.3350743932 149.084182978,-35.3350306311 149.085041285)', 4326));

But when I run a query to get the line back out of the database.

SELECT st_astext(line) from routes;

Result:

LINESTRING(-35.3350743932 30.915817022,-35.3350306311 30.914958715)

The latitude coordinates come out completely differently from how I inputted them. Can anyone point out to me why this would be?

I am new to PostGIS - I think I must be missing something about the storage and retrieval of 4326 data. Any help appreciated.

James Flight
  • 1,424
  • 1
  • 13
  • 21
  • 1
    Latitudes only range from -90 to +90, so I don't know where you are getting those values from! Looks like PostGIS is returning 180- your value. https://stackoverflow.com/questions/15965166/what-is-the-maximum-length-of-latitude-and-longitude – mlinth Feb 21 '19 at 11:22
  • Ah yep - this is just a classic case of me getting the coordinates backwards. Thought I'd double checked that, but clearly not! Thank you! – James Flight Feb 21 '19 at 12:22

0 Answers0