[R-sig-Geo] Combining spatial pixels objects

Mark Payne markpayneatwork at gmail.com
Tue Nov 19 14:58:10 CET 2013


Hi,

Consider a situation where I have a spatialpixelsdataframe, m.subset,
that is a subset of a larger dataframe, m. Due to the large size of my
dataset, its more efficient for me to work on just this subset, than
it is to work with the entire data set. Now, the question is, once
I've finished processing the subset, I want to add it back into the
original object. But the question is... how?

In terms of a code example, it might look like:

library(sp)
data(meuse.grid)
coordinates(meuse.grid) <- ~ x + y
m <- SpatialPixelsDataFrame(meuse.grid,meuse.grid at data)
m <- m[,"dist"]

#Split into a subset
m.subset <- subset(m,m$y > 333000)

#Do som fancy processing on m.subset e.g.
m.subset$dist <- m.subset$dist * 10

Now I want to combine the modified pixels in m.subset back into the
main object, m. Does anyone have any ideas how this might be done?

Best wishes,

Mark



More information about the R-sig-Geo mailing list