[FWTools] Re: ReadRaster syntax

Frank Warmerdam fwarmerdam at gmail.com
Mon Sep 5 22:15:17 EDT 2005


On 9/1/05, Bryan Keith <bryan at geomega.com> wrote:
> Hello,
> 
> I realize my original question may have not been very clear, but I
> solved my immediate problem.  The second row of a raster ought to be
> read like this:
> 
> band.ReadRaster(0,1,band.XSize,1,band.XSize,1,GDT_Float32)
> 
> not like I had guessed before.  So row n + 1 of a raster is read like this:
> 
> band.ReadRaster(0,n,band.XSize,2,band.XSize,1,GDT_Float32)
> 
> I'm still not totally clear what each parameter of the ReadRaster method
> is specifying.  If someone can point me to a help file, I'd appreciate
> it.  Thanks.

Bryan,

The ReadRaster() call has the arguments:

    def ReadRaster(self, xoff, yoff, xsize, ysize,
                   buf_xsize = None, buf_ysize = None, buf_type = None,
                   band_list = None ):


The xoff, yoff, xsize, ysize parameter define the rectangle on the raster file
to read.  The buf_xsize, buf_ysize values are the size of the resulting
buffer.  So you might say "0,0,512,512,100,100" to read a 512x512 block
at the top left of the image into a 100x100 buffer (downsampling the image). 

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the FWTools mailing list