This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

strange coordinates using OSM map

2

Hi I am making an app which uses a map downloaded from OpenStreetMap.

The map is of Edinburgh and I have used osm2pgsql to store the map in a PostGIS database.

Here is an example of the coordinates of points in the database when I execute the following query: select ST_AsGeoJSON(way) from planet_osm_point;

{"type":"Point","coordinates":[-397408.355686851020437,7575590.819041009992361]}
 {"type":"Point","coordinates":[-397373.846644709992688,7527300.011806310154498]}
 {"type":"Point","coordinates":[-397357.148721093020868,7514300.569031129591167]}
 {"type":"Point","coordinates":[-397356.035526185994968,7529052.908609829843044]}

These coordinates are different than coordinates I have taken of map websites such as: http://itouchmap.com/latlong.html where coordinates in Edinburgh are like: 55.951324,-3.188095

Does anyone know why this is and how I convert my coordinates into the normal coordinates that are used on these mapping websites?

Thanks

asked 30 Nov '12, 14:43

srose's gravatar image

srose
161101016
accept rate: 0%


One Answer:

6

The coordinates you are seeing are in a different projection (called "Spherical Mercator"). Either re-run your osm2pgsql import with the -l (ell) flag to have standard WGS84 lat/lon values in the database, or modify your query to select ST_AsGeoJSON(ST_Transform(way,4326)) to re-project on the fly.

answered 30 Nov '12, 15:10

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Source code available on GitHub .