[Gdal-dev] Filling a RasterBand with a constant value?

Simon Perkins s.perkins at lanl.gov
Fri May 2 02:01:29 EDT 2003


On Thu, 2003-05-01 at 23:45, Frank Warmerdam wrote:
> > So, do you think there's any need for a GDALrasterBand::Fill() method?
> > Based on past embarrassment, I'd better qualify that with: "Or is there
> > already a suitable method that does this?"!

> My first impression is that this is an unnecessary method, and wouldn't
> be used for much.  However, if you wish, you can implement and commit it
> as a virtual method on GDALRasterBand.  I would add that the the argument
> should be "(double dfRealValue, double dfImaginaryValue = 0.0 )", and that
> you might even want to provide for a rectangle to apply it over.
> 
> Drivers are not required to initialize new rasters to any particular value
> though of course they normally do initialize to zeros.

My motivation for doing this is ensure that an image is created filled
with the NODATA value. In this scenario, the image is initialized
completely with NODATA, and then certain sub-windows of the image are
overwritten with interesting values. The plan is then to display this
image as a semi-transparent overlay within a GIS system but have the
overlay be completely transparent in the NODATA areas.

I'll probably go ahead and add this, for this use, unless someone comes
up with a better way of achieving the above effect.

To keep things simple I'll probably just do the full band fill for now.
We can always add an optional rectangle argument later if there's a
need.

Thanks for the tips!

Cheers,

Sy





More information about the Gdal-dev mailing list