I have osm-file and I want to import it to the postgresql via osm2pgsql with custom projection EPSG:20022. I look to the help and found out any keys like -E EPSG: but when I try to do with it I get the data in SRID=4326. Is there a way how to fix it?


You can find the source code of osm2pgsql here:


and you will find this note in line 67:

/* hard-code the source projection to be lat/lon, since OSM XML always
* has coordinates in degrees. */
    pj_source = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");

    /* hard-code the tile projection to be spherical mercator always.
* theoretically this could be made selectable but not all projections
* lend themselves well to making tiles; non-spherical mercator tiles
* are uncharted waters in OSM. */
    pj_tile = pj_init_plus(Projection_Info[PROJ_SPHERE_MERC].proj4text);

    /* now set the target projection - the only one which is really variable */
    if (proj >= 0 && proj < PROJ_COUNT)


    fprintf (stderr, "Couldn't read EPSG definition (do you have /usr/share/proj/epsg?)\n");

I think it will be much easier for you to import the stuff using lat/long, and do the reprojection afterwards in the database.

The -E parameter seams to be implemented to choose EPSG:4326 or EPSG:900913, but others might not work.

For your postgis database, http://www.postgis.org/docs/ST_Transform.html shows you how to do a transformation. It is as exact as doing it by proj4, because it uses the same methods.

  • Thanks Andre for your reply. What does it mean? "do the reprojection afterwards in the database". Could you please show an example? Nov 25 '13 at 11:59
  • Also does it mean that -E key is unavailable anymore? What inaccuracy will be after reprojection? Nov 25 '13 at 12:07
  • I guess what Andre means is using a tool to do the projection transformation AFTER you worked with your data and still store it in EPSG:4326. The reprojection can be done using #pro4j or GIS tools like #QGIS. I'm not an expert, but IMHO the most OSM tools expect the default projection and will cause problems if there is something else...
    – Mapper
    Nov 25 '13 at 12:21
  • I extended my answer...
    – AndreJ
    Nov 25 '13 at 14:28
  • Andre, is it the same if I use something like: update osm_point set way=transform(way,20022); update osm_line set way=transform(way,20022); update osm_polygon set way=transform(way,20022); update geometry_columns set srid=20022 where f_table_name='osm_point'; update geometry_columns set srid=20022 where f_table_name='osm_line'; update geometry_columns set srid=20022 where f_table_name='osm_polygon'; Nov 25 '13 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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