[GIS] Merging raster data with different resolutions

gdalmergerasterresolution

I need to merge different raster datasets which have one layer and contain discrete values to a layer stack.
The resolutions of the data can have any value so not only multiples of the resolutions from the other input rasters thus there are problems with alignment. Also the corner coordinates are not necessarily identical.

Has anybody got a creative idea of what is the best way to do the merging without losing information as a layer stack can only have layers with the same resolution? I have used gdal_merge.py and of course there is quite some loss of information through the nearest neighbour resampling (though I must use nearest neighbour as I want to keep discrete values).

One thing I thought of was to polygonize each raster and then union them and rasterize the resuling polygon with a appropriate resolution. That would keep most information but here I am afraid that it will not work properly with large datasets. Perhaps somebody has experience with this?

Best Answer

No need to turn the raster into polygons.

You'll want to do it in multiple passes. First you want to resample the lower resolution dataset to as close as you can get and a multiple of the higher resolution dataset using bilinear interpolation which should get you a better looking resampling. Then do the merge as normal using your nearest neighbor (which I think gdal_merge.py can only do anyways).

For the first step you'd need to use gdalwarp with the -r bilinear or -r cubic option. This will get you a decent resampling to continue on with your merge. gdalwarp can also do the nearest neighbor if you wanted to use that in your second pass.

Related Question