Skip to content

Creating SpatialGridDataFrame - unequal number of objects

2 messages · Chris English, Edzer Pebesma

#
Dear List:
I have a SpatialGrid for which I am trying to make adata.frame and thence a SpatialGridDataFrame.
I can't seem to get the size of data.frame and gridto match up. ?I assume I'm missing something straight forward.

?summary(grid1)Object of class SpatialGridCoordinates:? min ? ?maxx 0.5 1824.5y 0.5 1368.5Is projected: NA?proj4string : [NA]Number of points: 2Grid attributes:? cellcentre.offset cellsize cells.dimx ? ? ? ? ? ? ? ? 1 ? ? ? ?1 ? ? ?1824y ? ? ? ? ? ? ? ? 1 ? ? ? ?1 ? ? ?1368> help(str)> bike_mat<- matrix(rep(1368:1, each=1824), ncol=1824, byrow=TRUE)> bike_df<- as.data.frame(bike_mat)> bike_sgdf_1<- SpatialGridDataFrame(grid1,bike_df)Error in validityMethod(object) :?? unequal number of objects in full grid and data slot
Thank you for you assistance.
Chris
#
Your example below is very hard to read. But if I understand it
correctly, the following change,

bike_df <- as.data.frame(as.vector(bike_mat))

may result in something that is syntactically correct; whether it does
what you want is not clear from the context.

Hth,
On 05/28/2011 06:18 PM, Chris English wrote: