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

How to convert OSM geometries to other coordinate reference systems?

2

Hi everyone,

I haven't found any useable source on the web which tells me how to convert data from OSM which I have imported with osm2pgsql into my postGIS database to another coordinate reference Systems (CRS) like UTM or lat/Long. How can I do this task with the integrated functions in the postGIS database or vice versa, how to convert data from another database with e.g. UTM coordinates to the format OSM is using?

Thanks, Stefan aka nordie69

asked 24 Jan '15, 20:47

nordie69's gravatar image

nordie69
45226
accept rate: 0%


2 Answers:

4

Unless you have specified a different CRS upon import (using the -l or -E), your import is in EPSG:3857 a.k.a EPSG:900913. To convert to a different CRS, use the PostGIS ST_Transform method:

SELECT name, ST_AsText(ST_Transform(way, 4326))
FROM planet_osm_point
WHERE amenity='pub';

answered 25 Jan '15, 00:40

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

2

Use standard PostGIS function st_transform(geometry,EPSG#). Using ST_Setsrid is useful to ensure the DB knows which co-ordinate system it is using. It is relatively easy to alter the standard table to add additional geometry columns, but the tables may not then be suitable for updates.

osm2pgsql allows the specification of the desired co-ordinate system as a flag on input. I'd use this if working predominantly in one co-ordinate system.

answered 25 Jan '15, 00:44

SK53's gravatar image

SK53 ♦
28.1k48268433
accept rate: 22%

edited 13 Mar '15, 16:08

Source code available on GitHub .