I have an issue trying to import OSM data on PostGIS.
I download an xml file from the CloudMade site.
I use this script to import the file into postgis (on Windows, latlong projection):
This works, but when I visualise the spatial data on uDIG (default projection: WGS84) proportions are wrong. The vertical axis is much shorter than it is on regular online maps (e.g. openstreetmap.org, google maps, etc), like here: http://img7.imageshack.us/img7/8279/imagelw.png
So I read somewhere that the OSM data is stored in mercator, and I tried to run the same script with -m option:
WGS84 is not a projection. With ‘-l’, you store the positions as lat/lon coordinates. That means that you have to select the projection later in your application. I don’t know uDIG but I would say that you have to set the right projection there.
Otherwise, you can create the data already projected in spherical mercator with the ‘-m’ flag (which is the default anyway). But for this, you also have to load as prerequisite in the db the sql script “900913.sql” provided with osm2pgsql. Check the wiki.
For the uDig user interface WGS84 means the same as EPSG:4326.
There should be no problem in viewing a map in whatever supported projection with uDig because it can change projections on-the-fly. If you have opened OSM data from PostGIS in native EPSG:4326 projection, just click the projection tab (in the middle underneath the map) and select 900913 (WGS84 / Google Mercator) any other suitable projection from the list and the map will look different.
I tested this with Windows XP, uDig 1.2 Milestone 9 version and PostGIS 8.2. I am not sure if reprojection is done totally on uDig side or if it makes queries to PostGIS with the selected projection. In the latter case also PostGIS must support EPSG:900913 as Pieren told. You can check if with SQL query
select * from spatial_ref_sys where srid=900913;
If definitions for the Google Mercator projection are missing you can find the SQL script from the same place than osm2pgsql utility.
You should see your data also with the other import option that you used. I cannot say why it failed for you. Perhaps the uDig “viewport” was outside the coverage of your data.
Thanks for your replies!
uDig doesn’t seem to support the Google Mercator EPSG:900913. The data on postgis seems ok, the srid is defined.
I can summarise what I’ve done:
I’m trying to render openstreetmap data on a WMS on MapServer.
The system used to work with epsg:4326 but in our project we need a GoogleMaps like projection and we chose epsg:900913.
These are the steps I followed to reimport everything for the new projection:
download osm xml file from Cloudmade (e.g. Italy.osm.bz2)
As I wrote, I downloaded uDig 1.2 M9 version and it did give me 900913 support out of the box.
I am always testing WMS first with something that gives me a better control about what is really happening. Usually I send hand written WMS requests directly from a browser.
You can see the requests sent by your OpenLayers application from your Apache access log file. With my Windows installation it is under ms4w\Apache\logs. Check that the BBOX and SRS makes sense. To compare with, some OL application using our server is sending something like this:
/cgi-bin/WMS?LAYERS=my_layer&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&TRANSPARENT=true&TILED=true&TILESORIGIN=1229757.5465712,8139734.3664411&SRS=EPSG%3A900913&BBOX=2829757.5465712,8459734.3664411,3149757.5465712,8779734.3664411&WIDTH=256&HEIGHT=256
I suggest also to add DEBUG 5 into LAYER definitions in your mapfile, it will lead to more information logged into your MS_ERRORFILE.
My guess it that there is something wrong with projections and Mapserver just does not find anything from the place defined by SRS and BBOX combination.