[gdal-dev] How to read first line pixel values of an image into buffer

Frank Warmerdam warmerdam at pobox.com
Thu May 20 08:09:58 EDT 2010


mail2vajram wrote:
> I am using the following code to read pixel values. It read only one pixel
> value..how to read entire row..
> 
> generally this code is used to read 0th column 1st row and return pixel
> value into buffer.  
> code:     
>  Band band = ds.GetRasterBand(1);
>  double[] buffer = new double[ds.RasterXSize];
>  band.ReadRaster(0, 1,1,1, buffer, 1,1, 1, 1);
> 
> 
> but when i am using the following code i am not able to getting entire first
> row values values.
> 
> Band band = ds.GetRasterBand(1);
>  double[] buffer = new double[ds.RasterXSize];
> band.ReadRaster(0, 1,ds.RasterXSize,1, buffer, 1, 1, 1, 1);
> 
> Can any body suggest me which parameter i need to change. Iam using C# code

Vajram,

band.ReadRaster(0,1,ds.RasterXSize,1, buffer, ds.RasterXSize, 1, 1, 1 )

Note that your yoffset (second parameter) is 1, so you are really
reading the second line.

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 gdal-dev mailing list