gdal raster datasource distorted after reprojection #1049

Open
demiurg opened this Issue Jan 24, 2012 · 3 comments

Projects

None yet

3 participants

@demiurg
demiurg commented Jan 24, 2012

When reprojecting data, some weird distortion creeps in that changes as you zoom in. You can see the change from http://eomf-dev.ou.edu/media/issue/1.png to http://eomf-dev.ou.edu/media/issue/2.png . When I gdalwarp reproject the data to mercator, the file is displayed without any distortion at all. This could be a proj problem, but it does not occur with MapScript, although there is some edge clipping in mapscript at the outmost zoom level, but not "noisy" distortion like this. I can also say that the original sinusoidal projection is pretty extreme, as it converges at the poles, this could be part of the issue.

I have the following relevant code:

modis_srs = "+proj=sinu +R=6371007.181 +nadgrids=@null +wktext"
merc_srs  = "+init=epsg:3857"
data = "path to tif"

tile = mapnik.Map(w,h, merc_srs)
...
layer = mapnik.Layer('modis', modis_srs)
layer.datasource = mapnik.Gdal(file=str(data),band=1) 
...
sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color("transparent"))
for color in [{'color': [130, 10, 10],  'stop': -0.1},
     {'color': [154, 58, 38],  'stop': 0.0},
     {'color': [178, 106, 66],  'stop': 0.1},
     {'color': [202, 154, 94],  'stop': 0.2},
     {'color': [250, 250, 150],  'stop': 0.3},
     {'color': [214, 234, 128],  'stop': 0.4},
     {'color': [178, 218, 107],  'stop': 0.5},
     {'color': [142, 202, 85],  'stop': 0.6},
     {'color': [107, 187, 64],  'stop': 0.7},
     {'color': [71, 171, 42],  'stop': 0.8},
     {'color': [35, 155, 21],  'stop': 0.9},
     {'color': [0, 139, 0],  'stop': 1},
     {'color': [-35, 124, -21],  'stop': 1.1}]:
        sym.colorizer.add_stop(color['stop'], mapnik.Color(*color['color']))

tile.zoom_to_box(mapnik.Envelope(*env)) #env contains meter unit bounding box from OL wms request
draw = mapnik.Image(tile.width, tile.height)
mapnik.render(tile,draw)

Relevant data:
http://eomf-dev.ou.edu/media/issue/1.png
http://eomf-dev.ou.edu/media/issue/2.png
http://eomf-dev.ou.edu/media/issue/evi_2000361_10km_mosaic.tif
http://eomf-dev.ou.edu/media/issue/evi_2000361_10km_mosaic_merc.tif

Can see more of this effect here: http://eomf-dev.ou.edu/visualization/olmap/

Komzpa commented Jan 24, 2012

#1035 might have somethin in common.

Owner

Thanks for the report. The on-the-fly reprojection is very new, so this certainly could be a bug in mapnik, not proj. But, your point is good that it may be the fancy clipping in mapserver that is protecting against this. We do not, in mapnik, try to catch any of the many meltdown possibilities in proj4.

Owner

Added XML to testcase and pushed into standalone gist: https://gist.github.com/springmeyer/3a689349e75578ccb3ec

@springmeyer springmeyer modified the milestone: Mapnik 3.x, Mapnik 2.1.1 Sep 6, 2014
@springmeyer springmeyer removed this from the Mapnik 3.x milestone Sep 24, 2014
@springmeyer springmeyer added the post3x label Sep 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment