Skip to content
Prev 274372 / 398506 Next

getting data associated with coordinates in a spatial data frame

Ah yes, my eternal nemesis the S4 class...

You were basically there with

e[e$coordinates==(0,17),]

but for some access stuff that comes from the SpatialDataPointsFrame class.

You'll probably want to do this in two steps:

coords = coordinates(e)
## Use the access function coordinates to get a 2xn matrix of
coordinates x and y;
## you could also do this with coords = e at coords as Weidong noted but
it's discouraged

e[coords[,"x"] == my.x & coords[,"y"] == my.y, "leachate"]

I can't test it on your data, but I think this will do it.

data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
M = meuse.grid

coords = coordinates(M)
 M[(coords[,"x"] == 179220) & (coords[,"y"] == 329620), "soil"]

Hope this helps,

Michael
On Thu, Oct 13, 2011 at 2:18 PM, Bailey, Daniel <bailed at spu.edu> wrote: