[Gdal-dev] How to efficiently read in a GDAL image into a matrix

Ryan Lewis me at ryanlewis.net
Wed Nov 7 14:15:34 EST 2007


Hi,

I would like to read in an entire ENVI image into a GDAL Dataset, and  
then, create a matrix the size of which is pixels X number of raster  
bands
So each column of the matrix is a raster band of the image, and each  
row is a pixel of the image.  so the idea is I would linearize the 2d  
raster band with something like the pixel at (x,y) in a particular  
rasterband would be at the position
x*width + y in the column.

Apparently it is a really bad idea to try and read one value at a  
time out of each raster band, so could someone just tell me the best  
method for doing this.

(If you have the code already that would be cool, but it is not  
necessary, just an outline of the best way to do this in GDAL would  
be awesome).

Thanks,

- Ryan H. Lewis




More information about the gdal-dev mailing list