Debian Codegraph @

R/select.spatial.R

raw
1 "select.spatial" <- function(data, digitize = TRUE, pch = "+",
2 rownames = FALSE)
3 {
4 if (!is(data, "SpatialPoints"))
5 stop("data should be of, or extend, class SpatialPoints")
6 x = coordinates(data)[, 1]
7 y = coordinates(data)[, 2]
8 plot(x, y, pch = pch, asp = 1)
9 if (rownames && is(data, "SpatialPointsDataFrame"))
10 labels = row.names(as.data.frame(data))
11 else
12 labels = 1:length(x)
13 if (digitize) {
14 pol = locator(n = 512, type = "o")
15 sel = 1:length(x)
16 sel = sel[point.in.polygon(x, y, pol$x, pol$y) > 0]
17 } else
18 sel = identify(x, y, labels = labels)
19 labels[sel]
20 }