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

David Shean dshean at gmail.com
Mon Nov 20 16:07:36 PST 2017


Hi all,
This is also possible with the dem_mosaic tool, part of the NASA Ames Stereo Pipeline toolkit.  The utility is multithreaded and meant to handle an arbitrary number of large rasters efficiently.  You want the ‘—max’ command line option.

Unfortunately, the official NASA ASP site is currently down, but you can download precompiled binaries for Linux and OS X here: https://github.com/NeoGeographyToolkit/StereoPipeline/releases.  See the asp_book.pdf for documentation and usage on dem_mosaic.

Hope that helps.
-David


> On Nov 20, 2017, at 1:48 PM, Nicolas Cadieux <nicolas.cadieux at archeotec.ca> wrote:
> 
> 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 <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 <mailto: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 <mailto:gdal-dev at lists.osgeo.org>
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev <https://lists.osgeo.org/mailman/listinfo/gdal-dev>_______________________________________________
> 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/73ad99ac/attachment.html>


More information about the gdal-dev mailing list