Friday 12 June 2015

epsg - Projected layer misaligned with Mapserver


I have a couple or raster files in epsg:23031 reference that i want to reproject to other reference systems (epsg:4326 and google projection) using the 'on the fly reprojection' of Mapserver.


No problems using the default projection. But when i try to overlap my layer (in epsg:4326) with google earth there is a 100m misalignment between the two of them.


Any ideas?


Here is the map file:


MAP
NAME topo

IMAGECOLOR 125 125 125

SIZE 600 400
RESOLUTION 96
RESOLUTION 300

MAXSIZE 4096
STATUS ON

PROJECTION

"init=epsg:23031"
END

OUTPUTFORMAT
NAME png
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END


OUTPUTFORMAT
NAME GEOTIFF_RGB
DRIVER "GDAL/GTiff"
MIMETYPE "image/tiff"
IMAGEMODE RGB
EXTENSION "tif"
END

EXTENT 443275 4647717 488074 4691799


WEB
IMAGEPATH "C:\OSGeo4W/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
METADATA
"wms_srs" "EPSG:4326 EPSG:900913"
END
END
LAYER
NAME orto

PROJECTION
"init=epsg:23031"
END
TYPE RASTER
DUMP TRUE
STATUS ON
TILEINDEX "orto.shp"
TILEITEM "LOCATION"
EXTENT 443275 4647717 488074 4691799
END

END

I'm using mapserver 5.6.4 that comes with osgeo4w tools



Answer



I believe that the issue that you are seeing is the result of proj4 (the projection engine behind gdal/mapserver) is not doing the datum transformation for you. This is likely because there are several options for data transforms between 23031 and WGS84 and proj.4 no longer defaults to one of them.


Take a look at this explanation: http://trac.osgeo.org/proj/wiki/GenParms#towgs84-DatumtransformationtoWGS84


If you specified a towgs parameter, you may get a more accurate transformation. If you are requesting the map from MapServer using a normal URL call, you could define your output projection using the proj4 text instead of an EPSG code, something like:


PROJECTION proj=utm zone=31 ellps=intl units=m towgs84=-87,-96,-120 no_defs END


I came up with the towgs84 parameter based on the table here: http://earth-info.nga.mil/GandG/coordsys/onlinedatum/CountryEuropeTable.html You might be able to come up with a better one yourself.


I believe that you are requesting the image to overlay in Google Earth as a WMS, so you will need to modify the epsg database to include the towgs parameter for epsg 23031.



Your EPSG database should be at: C:/OSGeo4W/share/proj/epsg


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...