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

Iván Sánchez Ortega ivan at sanchezortega.es
Thu May 20 07:39:24 EDT 2010


El 20/05/2010 9:30, mail2vajram escribió:
> I am using the following code to read pixel values. It read only one pixel
> value..how to read entire row..

Use a loop?

> 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);

No. That's 1st column, 2nd row. You have to start counting from zero.

> 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);

You're completely ignoring the buf_xSize and buf_ySize parameters.

-- 
Iván Sánchez Ortega <ivan at sanchezortega.es>


More information about the gdal-dev mailing list