Skip to content
Prev 274371 / 398506 Next

getting data associated with coordinates in a spatial data frame

Hi,
On Thu, Oct 13, 2011 at 2:05 PM, Bailey, Daniel <bailed at spu.edu> wrote:
They "don't become a single column" but rather a single matrix with
two columns, and (0, 17) isn't the correct way to specify a vector.
You can identify particular coordinates using the form I offered
earlier, and then use that to subset the data slot of your SGPF.

Using built-in data:

library(sp)
data(meuse.grid)
m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data = meuse.grid)
m at data[coordinates(m)[,"x"] == 181100 & coordinates(m)[,"y"] == 333660,]

There ought to be a more elegant way to match coordinates (other than
the do.call() and paste() approach), but I'm not sure what it is.

Sarah