robinkraft / forma-vis

Code for visualizing forest clearing data over time using HTML5 and visualraster
1 stars 0 forks source link

gdal2tiles resampling introduces pixel artifacts #5

Closed robinkraft closed 12 years ago

robinkraft commented 13 years ago

Example: http://elementstream.com/forma-vis/tiles/newecohack/10/824/515.png

If you zoom way in you can see borders on the real pixels.

The good news is that it's not a canvas-related problem. Nor is it an error in the original data. Turns out it's introduced by gdal2tiles.py, which by default resamples the original image using the average of the pixel neighborhood. I can regenerate the tiles using the nearest neighbor option, which should not change the pixel values (though it could shift them slightly - not enough to matter).

Solution: regenerate tiles using gdal2tiles using --resampling=near flag.

robinkraft commented 12 years ago

I've taken care of the tiling artifacts in this new tile directory:

http://s3.amazonaws.com/forma-vis/forma_low_zoom/

It only goes to zoom 7, but unless I increase the resolution of the input data we're going to see similar artifacts even if we use the nearest neighbor resampling algorithm. This is because gdal2tiles generates the base tiles first - which requires resampling past zoom level 7 for this dataset - and then uses four of those base tiles, and resamples the four stitched-together tiles to create the appropriate tile at the lower zoom level (e.g. 6). So the data artifacts introduced in the base tiles cascade through the rest of the zoom levels.

In short, for the moment we'll have to be satisfied with zoom level 7. We're prepping a new data release at 500m resolution for Indonesia, which will get us up to zoom level 9 I believe without requiring resampling for base tiles. Then if we want higher zooms we'll have to mess with the input image so that we have correctly-sampled base tiles at higher resolution.