[gdal-dev] How to make VRT offsite areas white?

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Mon May 28 07:28:15 PDT 2012


Even Rouault <even.rouault <at> mines-paris.org> writes:


> - cheat a bit and create a white image that you add as the first position in
> your VRT.
> 
> This can be a single pixel image that you artifically expand to full VRT size,
> like this :
> 
>       <SrcRect xOff="0" yOff="0" xSize="1" ySize="1"/>
>       <DstRect xOff="0" yOff="0" xSize="replace_by_vrt_x_size"
> ySize="replace_by_vrt_y_size"/>


This was the ultimate guru solution - simple, extremely fast and totally
undocumented.

I made an one pixel sized image "onepixel.tif" as you suggested and placed the
following SimpleSource as the first source for each band

<SimpleSource>
              <SourceFilename relativeToVRT="1">onepixel.tif</SourceFilename>
              <SourceBand>1</SourceBand>
              <SrcRect xOff="0" yOff="0" xSize="1" ySize="1" />
              <DstRect xOff="0" yOff="0" xSize="2000" ySize="2000" />
</SimpleSource>

Knowing tricks is fun but I could tolerate having some parameter driven way for
setting the VRT background colour.

-Jukka Rahkonen-




More information about the gdal-dev mailing list