[gdal-dev] gdal_translate of VRT file with overlapping files. Target pixel value selection.

Even Rouault even.rouault at spatialys.com
Fri Jan 25 10:58:55 PST 2019


On vendredi 25 janvier 2019 14:36:23 CET Christoph Paulik wrote:
> Hi,
> 
> We have a VRT file in which some regions overlap. As far as I can tell
> a gdal_translate of the VRT into a GTIFF just takes the value of the
> first file it encounters for a given target pixel.

Actually, this will be the value of the last (as ordered in the VRT) source 
that covers the target pixel.

> 
> Is there a way to specify an averaging method for such cases e.g. take
> the mean, max, min etc.?
> If not possible yet would that be a feature that would be of interest?

You could do that in two steps:
- for each source, create a VRT from it whose extent is the union of the 
extents, and set a nodata value.
- and then create a VRT of thoses VRT using a derived band:
https://www.gdal.org/gdal_vrttut.html#gdal_vrttut_derived_c
The existing default pixel functions do not cover your need, so you could use 
instead a pixel function written in Python:
https://www.gdal.org/gdal_vrttut.html#gdal_vrttut_derived_python

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list