extracting row of data in a SpatialGridDataFrame object
bio_grid[1,] is the first row of the grid (think of the grid as a matrix), not the first row of the data.frame with attributes. Although direct manipulation of slots is not recommended in general, in case of large objects it may be useful to address the data values at grid cells directly by the data.frame that carries them: bio_grid at data; its first row is bio_grid at data[1,] Hth,
On 05/29/2012 02:35 PM, Elena_C wrote:
Hello all, I believe my question must be quite basic, but I've spent quite some time and I haven't managed to figure it out on my own, so any help would be greatly appreciated. I have a SpatialGridDataFrame object and I'm trying to extract the associated data, by both rows and columns, as vectors. Ive managed to get the columns to work with the operator [[ ]]:
class(bio_grid)
[1] "SpatialGridDataFrame" attr(,"package") [1] "sp"
dim(bio_grid)
[1] 43200 33
class(bio_grid[[1]])
[1] "numeric"
length(bio_grid[[1]])
[1] 43200 Is it possible to do the same with rows instead of columns? I'm not sure what "bio_grid[1,]" does, but it is not the first row of the data frame:
dim(bio_grid[1,])
[1] 360 33 I know it is possible to extract the data.frame and work with it normally: bio_data <- data.frame(bio_grid) Extract row number 'i': bio_data[i,] But I was wondering if it could be done directly from the SpatialGrid, because I have very large objects and my computer takes forever and sometimes hangs up when I try to extract the data.frame Thanks a lot, Elena -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/extracting-row-of-data-in-a-SpatialGridDataFrame-object-tp7579385.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de http://www.52north.org/geostatistics e.pebesma at wwu.de