mapnik-org/mapnik — Issue #293: Adjacent (gdal) rasters alignment
Author: artemp
Created: 2011-10-11 07:47:06+00:00
State: open
Labels: GDAL_Input_Driver

When trying to draw adjacent raster files, to achieve smooth hillshading using more then one raster, there is missalignment.

The problem is conversion from range extend in float values to int image position and height. I.e. 399.999999998 goes to 399 and in effect, two adjacent rasters are misalignment even in perfect conditions.
I attached fix, that uses rounding using:

int(float_value+0.5)

This way, it is possible to use multiple rasters to cover area with only little artifacts coming from interpolation (unable to predict next value on edge).

Unfortunatelly, when interpolating scaled version, there are still possible small artefacts, that can be explained with this simple
example:

With one big raster You have:
{{{
Source: A C E G I K
Scaled: A b C d E f G h I j K ?
}}}

and with two adjacent rasters:
{{{
Source: A C E | G I K
Scaled: A b C d E ? | G h I j K ?
}}}

f would be E+G/2, but in second case, G is unknown in first raster, so
interpolation could assigns only value E (same with K in both cases).

Solution to this would be using multiple raster files in one Layer, and
scaling/composing merge of all in actual projection window. Now I have
to create separate layer for each tiff.

Another solution would be passing one pixel wider/higher image to scaling and additional row/column would be then used only to handle interpolation at edge. Also rasters should be provided with 1px overlaping then for this to work.