[gdal-dev] building a vrt to stack overlapping COGs with a mask/alpha band
Landry Breuil
breuil at craig.fr
Wed Jul 8 01:12:31 PDT 2020
Hi,
i'm converting a stock of tiled aerial pictures (from distinct
years/campaigns) to COG (using gdal 3.1.0), and trying to stack them via
a vrt. the COG arent 'full', in the sense that they have a bbox, but
there isnt data *everywhere*. Some of those campaigns/COGs have
overlapping BBOXes.
the COG are built from vrts (assembling all the tiles for the campaign)
built with -addalpha, and then using gdal_translate -of COG -b 1 -b 2 -b
3 -mask 4 to have the mask band in the resulting COG, ie i get 3 bands
with a 'per-dataset mask':
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
Overviews: 148000x172000, 74000x86000, 37000x43000, 18500x21500,
9250x10750, 4625x5375, 2313x2688, 1157x1344, 579x672, 290x336
Mask Flags: PER_DATASET
Overviews of mask band: 148000x172000, 74000x86000, 37000x43000,
18500x21500, 9250x10750, 4625x5375, 2313x2688, 1157x1344, 579x672, 290x336
i have zero issue loading the separate COGs in QGIS (locally or via
vsicurl), the nodata areas are properly displayed as transparent,
loading several COGs on top of each other properly render the
overlapping areas, ie if at some coords there's data in the lower COG
and nodata in the toplevel COG, then the data from the lower COG is
rendered. That can also be achieved via a mapserver GROUP, loading the
layers on top of each other, as seen in https://imgur.com/9BgZSTH.png
Trying to achieve the same via a vrt file stacking the COGs fails (plain
gdalbuildvrt img1.tiff img2.tiff), ie for the same coords, nodata will
be rendered if there's nodata in the toplevel COG (even if there's data
in the lower COG), and that for the complete BBOX of the toplevel COG
(ie outside of the toplevel COG BBOX, data from the lower COGs is
displayed). See https://imgur.com/a/HiEfjxY for an example (here, it's
via WMS loading as jpeg, using png the white area would be transparent).
I tried playing with the various gdalbuildvrt (-addalpha, etc..) options
but i still cant figure out what is the correct incantation to achieve
my goal (ie tell gdalbuildvrt that there's some kind of 'cutline' around
the given COGs ?), so i'm resorting to find hints on the list :)
TIA,
Landry
More information about the gdal-dev
mailing list