[gdal-dev] Merge many raster using maximum value where overlaps

Nicolas Cadieux nicolas.cadieux at archeotec.ca
Mon Nov 20 13:48:49 PST 2017


Hi,

You may be able to do that with the Saga grid mosaic.  You can select ´max’ for overlapping areas.  

http://www.saga-gis.org/saga_tool_doc/2.3.0/grid_tools_3.html

 Nicolas

> Le 17 nov. 2017 à 15:05, Rousseau Lambert2, Louis-Philippe (EC) <louis-philippe.rousseaulambert2 at canada.ca> a écrit :
> 
> 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
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171120/592d1b7c/attachment.html>


More information about the gdal-dev mailing list