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.