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

Even Rouault even.rouault at mines-paris.org
Mon May 28 08:53:12 PDT 2012


Selon Jukka Rahkonen <jukka.rahkonen at mmmtike.fi>:

> 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.

Actually, I'm just thinking that there's another less convoluted way of doing
it. Try using "-vrtnodata 255 -hidenodata" as options of gdalbuildvrt. (This was
added in https://trac.osgeo.org/gdal/ticket/3327 )

>
> -Jukka Rahkonen-
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list