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
146101015
accept rate: 0%


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.

permanent link

answered 30 Nov '12, 15:10

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
60.6k74564949
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×448
×96
×92

question asked: 30 Nov '12, 14:43

question was seen: 3,059 times

last updated: 30 Nov '12, 15:10

powered by OSQA