View source: R/extract_spatial.R
extract_spatial | R Documentation |
This function utilizes 'sp::over' to select features that overlay on an input polygon. As no method is defined for SpatialLines, only Polygons and Points may be selected.
extract_spatial(in_spatial, over_poly = NULL, plot_result = FALSE)
in_spatial |
The sp object from which to extract features |
over_poly |
A polygon that specifies the features to extract. used in non-interactive mode. NOT YET IMPLEMENTED |
plot_result |
Boolean to plot the resulting features and selection poly. |
## Not run:
x <- c(0.5, 0.5, 1.2, 1.5)
y <- c(1.5, 0.5, 0.5, 0.5)
xy <- cbind(x,y)
dimnames(xy)[[1]] <- c('a', 'b', 'c', 'd')
pts <- SpatialPoints(xy)
xpol <- c(0,1,1,0,0)
ypol <- c(0,0,1,1,0)
pol <- SpatialPolygons(list(
Polygons(list(Polygon(cbind(xpol-1.05,ypol))), ID='x1'),
Polygons(list(Polygon(cbind(xpol,ypol))), ID='x2'),
Polygons(list(Polygon(cbind(xpol,ypol-1.05))), ID='x3'),
Polygons(list(Polygon(cbind(xpol+1.05,ypol))), ID='x4'),
Polygons(list(Polygon(cbind(xpol+.4, ypol+.1))), ID='x5')
))
extract_spatial(pts,T)
extract_spatial(pol,T)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.