[Gdal-dev] GDALRasterIO
Frank Warmerdam
warmerdam at pobox.com
Sun Feb 19 11:10:43 EST 2006
salah jubeh wrote:
> Hi guys
>
> I would like dump the content of image into an array to do some
> processing; I was able to extract rows
>
> But I want to extract the whole image band how this can be done
>
> I used this code
>
> nXSize = GDALGetRasterBandXSize( hBand );
> nYSize = GDALGetRasterBandYSize( hBand );
>
> pafScan = (float *) CPLMalloc(sizeof(float)*nXSize*nYSize);
> GDALRasterIO( hBand, GF_Read, 0, 0, nXSize, nYSize,
> pafScan, nXSize,nYSize,GDT_Float32,
> 0, 0 );
> But still when I say pafScan[10,10] it give me the value of 10^th pixel
> in the first row
Salah,
How was pafScan declared? If it is simply "float *pafScan;" then it
is a 1D array and you would need to do the 2d to 1d conversion yourself.
eg.
read pafScan[10 + 10 * nXSize]
The code itself looks fine for reading the whole band at once.
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