I am preparing tiff elevation files. For one particular country I have a 10 meter elevation model, but the data is present only for the specific country – so when the image is sliced into smaller parts – for example 0.1 x 0.1 degree – there are null (no data) values outside the country's border. I have figured out that I can use gdalwarp -r bilinear 10M_tiff.tiff 30M_tiff.tiff out.tiff
file to merge 10M and 30M tiff. But this command merges files fully. Is it possible to add additional parameters to the gdalwarp
command so it will add values from 30M tiff only in the case that data in the 10M tiff is missing? (I would like to preserve original 10m elevation data where possible)
[GIS] gdalwarp – merge two images, but only the no-data values
gdalwarpgeotiff-tiffmerge
Best Answer
I think a way to achieve what you're trying to do is
gdal_merge.py
(i.e., a Python command line tool, see http://www.gdal.org/gdal_merge.html). In case of overlap, that tool will take the cells of the last named raster rather than those of any previous rasters, so listing the 10m raster last will ensure it's values are used when there's overlap. In that case you need to specify the output cell resolution, since the tool takes that of the first raster as default. Syntax would be something like:Unfortunately, I don't see a way to specify the resampling method used this way, and I don't know what the tool uses by default.
Another approach might be to use
gdalwarp
, as you suggest, merging the 10m Tiff into a pre-existing copy of the 30m raster, and using the overwrite option (GDAL >= 1.8.0, see http://www.gdal.org/gdalwarp.html). I think that would replace the 30m elevation values with the new 10m ones. Something like: