[Gdal-dev] Re: [R-sig-Geo] working with Z values in spatial data frames

Michael Sumner mdsumner at utas.edu.au
Sat Nov 10 19:19:29 EST 2007


I know GDAL allows it, and it flows naturally into the data.frame model 
in R, but the GDAL gods consider the case of multiple bands of different 
types to be pathological. (I think).

This will give you the matrix:

as.image.SpatialGridDataFrame()$z

That's not a class-definition based "as" coercer, because "image" is not 
a class. It's just a well supported data structure in R.

Cheers, Mike.
>
>
>
> ------------------------------------------------------------------------
>
> Subject:
> [Gdal-dev] Re: Gdal-dev Digest, Vol 42, Issue 15
> From:
> Tim Keitt <tkeitt at gmail.com>
> Date:
> Sat, 10 Nov 2007 02:37:37 +0000 (UTC)
> To:
> gdal-dev at lists.maptools.org
>
> To:
> gdal-dev at lists.maptools.org
>
>
> Michael Sumner <mdsumner <at> utas.edu.au> writes:
>
>   
>> 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.
>>     
>
> GDAL handles different data types per band just fine. Some file format drivers
> may disallow different types, but the GDAL API does not have this constraint.
>
> Re the original post, I don't use sp classes that often, but I assume there is a
> method to convert a SGDF to an ordinary data frame or matrix. Simply call
> readGDAL and then convert to a matrix, probably using the "as" method.
>
> THK
>
>
>
>   




More information about the gdal-dev mailing list