[gdal-dev] Merge many raster using maximum value where overlaps
Rousseau Lambert2, Louis-Philippe (EC)
louis-philippe.rousseaulambert2 at canada.ca
Fri Nov 17 12:05:52 PST 2017
Hi everyone,
I would like to have your opinion on some processing I have to do.
So I have to merge many rasters (eventually more then 50). Some overlaps
(never completely), but others don't, my files when merged cover Canada.
I have to keep the maximum value where there is some overlap between
different files.
My first try was to use gdal_calc with --calc="maximum(A,B)", but it can
only input 26 files at a time. And The output of gdal_calc is only the
region of overlap, in my case I have to keep the whole extent of my
rasters, not only the region of overlap... Is there a way I could use
gdal_calc and keep everything, not only the overlap?
My second try was to use gdalwarp with a vrt of all my files as input
and use -r max for my resampling. My results were that it only
overlapped my geotiff and did not took the maximum value.
My last try, was to use gdalwarp to ensure that all my files have the
same extent and that pixel overlap perfectly. Then I create a mosaic
using gdal_merge of all my rasters. At this point I don't manage yet the
maximum value. Then I loop trough all my geotiff using gdal_calc to
output the overlap region between one geotiff and my mosaic. then I can
merge the overlap region with my mosaic. Finally I get a mosaic of the
maximum value where my raster overlap.
I don't really like this solution because if I have 50 files, I have to
use gdal_calc 50 times and merge the result 50 times... That seems a lot
of processing to simply get the maximum value in a mosaic.
Can you think of a better way to do? Any thoughts or opinions are welcome!
Louis-Philippe R. Lambert
More information about the gdal-dev
mailing list