On Thu, Oct 13, 2011 at 2:44 PM, Bailey, Daniel <bai...@spu.edu> wrote:
> Michael, that's half of the problem solved (whew!!). Now how do I change the 
> data at that location?

You assign it a new value, just as for any assignment. Using the
example from my previous email:


> data(meuse.grid)
> m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data = 
> meuse.grid)
>
> m@data[coordinates(m)[,"x"] == 181100 & coordinates(m)[,"y"] == 333660,]
       x      y part.a part.b dist soil ffreq
5 181100 333660      1      0    0    1     1
>
> m@data[coordinates(m)[,"x"] == 181100 & coordinates(m)[,"y"] == 333660, 
> "soil"] <- 5
>
> m@data[coordinates(m)[,"x"] == 181100 & coordinates(m)[,"y"] == 333660,]
       x      y part.a part.b dist soil ffreq
5 181100 333660      1      0    0    5     1
>


> This is not an intuitive way to manipulate data.

That's not what it's *for*. SGDFs are for storing and working with
spatial data, where all the components are needed for the spatial
reference. If you need to manipulate a lot of things, you're better
off doing it before you construct the SGDF, or you can cheat by
extracting the data slot, working with it, then reassigning it as a
single unit.

mydata <- m@data
# do stuff
m@data <- mydata

You might also benefit from reading "Applied Spatial Data Analysis
with R" by Bivand et al.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to