5

So I've imported a osm dataset into a PostGIS db using osm2pgsql, however when I call

ST_asText( way )

I get weird coordinates like

"POINT(16767838.9 -4051592.94)"

What format are these longitude latitude points? How do I convert them to I guess "normal" longitude latitude points like

"lat":-36.51985035227977,"lng":148.04298681640626
3
  • what area of the world are you working in?
    – ed.hank
    Sep 16, 2015 at 14:20
  • openstreetmapdata.com/info/projections. this shows the normal projection of the osm. you should use a transform to get the data to ll84 if that is what you desire.
    – Brad Nesom
    Sep 16, 2015 at 14:22
  • Try select ST_AsText(ST_Transform(way, 4326))
    – user30184
    Sep 16, 2015 at 14:28

2 Answers 2

3

If you never want to use web mercator coordinates you can import using the osm2pgsql --latlong option. That will store the coordinates as wgs84 lat/lon.

See the osm2pgsql command line docs for further information: https://github.com/openstreetmap/osm2pgsql/blob/master/docs/usage.md

2

OSM stores coordinates in Web Mercator projection, EPSG:3857.

as @user30184 says, transform them to EPSG:4326 (that is, wgs84 lat/lon) using

select ST_AsText(ST_Transform(way, 4326))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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