NOTE: GDAL > v2.0.0 is needed. Assumes running from a unix-like system with prereqs installed.
- put all the input files in a directory; name w/ extension .tif; cd to that dir
- build the vrt
gdalbuildvrt -a_srs EPSG:4326 my_overview_file.vrt *tif
- edit the vrt xml to include your mosaic algorithm example:
<VRTRasterBand dataType="Byte" band="1" subClass="VRTDerivedRasterBand"> <PixelFunctionType>maximu</PixelFunctionType> <PixelFunctionLanguage>Python</PixelFunctionLanguage> <PixelFunctionCode><![CDATA[ import numpy as np def maximu(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize, buf_radius, gt, **kwargs): np.round_(np.clip(np.max(in_ar, axis = 0),0,11), out = out_ar) ]]></PixelFunctionCode>
- NOTE: the indention on the python code will probably copy and paste wrong and you will need to fix it manually
- NOTE: the "0" and "11" usied in np.clip should be set to match your output bounds; 15, 31, 63, 127, 255 are other common values.
- enable python execution
export GDAL_VRT_ENABLE_PYTHON=YES
- make an "overview" at scale 1:1:
gdaladdo --config BIGTIFF_OVERVIEW YES -ro my_overview_file.vrt 1
- (optional) make additional changes to the result using gdal_edit
gdal_edit.py -a_srs EPSG:4326 my_overview_file.vrt.ovr
Running for swtx: