artemp/trac2github — Issue #680: projection comparison is problematic if srs (proj4 string) is used
Author: artemp
Created: 2011-10-09 20:46:45+00:00
State: open
Labels: Agg_Renderer

Currently comparison of projections for raster data sources and generated map seems to be done by comparing their proj4-strings (see also #663). Unfortunately this is problematic: At least for the ubiquitously used spherical mercator projection there seems to be more than one valid proj4-coding for the same projection.

At least I have an example, where the raster was created using gdalwarp with -tsrs as
{{{
+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over
}}}
(which used to work fine and was well aligned with other data in older mapnik versions, which obviously did not check the srs),
but the error message generated by mapnik now is
{{{
WARNING: Map srs does not match layer srs, skipping raster layer 'raster' as raster re-projection is not currently supported (http://trac.mapnik.org/ticket/663)
map srs: '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs -tl -r'
layer srs: '+proj=merc +ellps=sphere +R=6378137 +a=6378137 +units=m'
}}}
As I do not set the layer srs explicitly, I assume that the "+ellps=sphere" comes from the GeoTIFF file, which does not include the projection as a proj4-string but as WKT. And in reverse-engineering this again to a proj4-string, it does not match the original string any more. For this GeoTIFF, gdalinfo shows me:
{{{
Driver: GTiff/GeoTIFF
Files: raster/linz_hillshade.tif
Size is 8630, 8165
Coordinate System is:
PROJCS["unnamed",
GEOGCS[,
DATUM["unknown",
SPHEROID["unnamed",6378137,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",1],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]]]
Origin = (1430906.247177651617676,6258780.161100597120821)
Pixel Size = (30.000000000000000,-30.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 1430906.247, 6258780.161) ( 12d51'14.58"E, 48d54'18.49"N)
Lower Left ( 1430906.247, 6013830.161) ( 12d51'14.58"E, 47d26'16.10"N)
Upper Right ( 1689806.247, 6258780.161) ( 15d10'47.24"E, 48d54'18.49"N)
Lower Right ( 1689806.247, 6013830.161) ( 15d10'47.24"E, 47d26'16.10"N)
Center ( 1560356.247, 6136305.161) ( 14d 1'0.91"E, 48d10'36.19"N)
Band 1 Block=8630x1 Type=Byte, ColorInterp=Gray
NoData Value=0
}}}