Adjacent (gdal) rasters alignment #295

Closed
artemp opened this Issue Oct 11, 2011 · 3 comments

Comments

Projects
None yet
1 participant
Owner

artemp commented Oct 11, 2011

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.

Owner

artemp commented Oct 11, 2011

[mar_rud] Sample geotiff rasters and more comparision images at:[[BR]]
http://marcom.homeip.net/ump-www/mapnik/ [[BR]]
where:[[BR]]

  • image2_*a.png : reference files with one raster[[BR]]
  • image2_*b.png : two separate layers after fix[[BR]]
  • image2_*c.png : two separate layers befor fix

image2_*a.png are made from merged hlt.tif, hrt.tif files using:[[BR]]
gdal_merge.py hlt.tif hrt.tif -o merged.tif

Owner

artemp commented Oct 11, 2011

[springmeyer] Marcin, this looks great.

My only thought is whether a similar tweak will be needed to the Raster input plugin as you have made to the gdal plugin.

I will let Artem take a look at this before applying, but great patch!

Owner

artemp commented Oct 11, 2011

[springmeyer] Thanks Marcin!

Artem ok'd in #mapnik and I've applied in r1079

artemp closed this Oct 11, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment