[gdal-dev] How to make VRT offsite areas white?
Rahkonen Jukka
Jukka.Rahkonen at mmmtike.fi
Mon May 28 07:03:40 PDT 2012
Even Rouault wrote:
>
> Selon Jukka Rahkonen <jukka.rahkonen at mmmtike.fi>:
>
> > Hi,
> >
> > I thought this would be easy but it was not.
> >
> > I have a mosaic of images which do not fill the whole
> bounding box of the
> > area.
> > I made a .VRT file the images and converted the virtual
> raster into geotiff.
> > Now
> > I have a nice mosaic but it has black boxes in the areas
> where I do not have
> > source data. An example of the result is here
> > http://latuviitta.org/documents/nodata_3.tif
> >
> > I would rather paint nodata areas with white instead of
> black. But how can I
> > make it? I thought that gdalwarp -dstnodata would do it but
> areas of missing
> > source data remains black
> > gdalwarp -dstnodata "255,255,255" nodata.vrt nodata_3.tif
> >
> > The following command does make the black box white but
> unfortunately is is
> > also
> > changing everything that was black in the orininal images,
> including all the
> > texts, into white:
> > gdalwarp -dstnodata "255,255,255" -srcnodata "0,0,0"
> nodata.vrt nodata_3.tif
> >
> > So what is the correct way to do this simple task?
>
> Jukka,
>
> Several options :
>
> - use the -addalpha option of gdalbuildvrt
Doing
gdalbuildvrt -addalpha nodata_alpha.vrt *.tif
and then
gdalwarp -dstnodata "255,255,255" nodata_alpha.vrt white_nodata.tif
makes the desired result.
> - use nearblack -setalpha ( http://gdal.org/nearblack.html ) ?
Did not try this one.
> - 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"/>
I have nothing against cheating and I will try this with my real dataset. Dataset is pretty big and running it through gdalwarp takes several hours more time than running it through gdal_translate.
> Best regards,
Thank you once again.
-Jukka-
>
> Even
>
More information about the gdal-dev
mailing list