[Gdal-dev] Re: Gdal-dev Digest, Vol 42, Issue 15
Michael Sumner
mdsumner at utas.edu.au
Fri Nov 9 17:24:39 EST 2007
This is actually a reasonably close description of how R's sp package
represents a gridded dataset as as SpatialGridDataFrame, readable by
readGDAL via rgdal.
In R the data is stored as a "data frame" - which is basically a list of
same-length vectors that is matrix-alike via methods. (Real matrices in
R are just vectors with a "dim" attribute and appropriate methods). For
SGDF each row holds each pixel's value, one column per band. In R the
data frame structure allows bands of different data type, a pathological
GDAL scenario but very useful in R generally.
I don't get what you want to do with it once you have represented it as
a "matrix", but maybe this gives you another option.
Cheers, Mike.
>
> ------------------------------------------------------------------------
>
> Subject:
> [Gdal-dev] How to efficiently read in a GDAL image into a matrix
> From:
> Ryan Lewis <me at ryanlewis.net>
> Date:
> Wed, 7 Nov 2007 14:15:34 -0500
> To:
> gdal-dev at lists.maptools.org
>
> To:
> gdal-dev at lists.maptools.org
>
>
> 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