Description Usage Arguments Value See Also Examples
Subset IBRA 7 to those polygons that contain, or are adjacent to polygons that contain, one or more given points.
1 2 | adjacent_ibra(pts, min_n = 1, include_type = "polygon",
expand_type = include_type, plot_output = FALSE)
|
pts |
A SpatialPoints* object. |
min_n |
The minimum number of points a subregion must contain in order for it to be included in the returned subset. |
include_type |
Character. Either |
expand_type |
Character. Either |
plot_output |
Logical. Should the resulting polygon subset be plotted?
If |
A SpatialPolygonsDataFrame
representing the subset of regions
(or subregions, see type
) of ibra7_albers
within which
min_n
or more points (pts) fall, and those regions (or subregions)
adjacent to these.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | library(sp)
xy <- SpatialPoints(data.frame(x=runif(1000, 140, 145), y=runif(1000, -38, -35)))
proj4string(xy) <- '+init=epsg:4283'
#' # Polygons with at least 1 point
adj <- adjacent_ibra(xy, include_type='polygon')
plot(adj, col='gray80', border='transparent')
# Polygons with at least 20 points
adj2 <- adjacent_ibra(xy, include_type='polygon', min_n=20)
plot(adj2, col='gray60', border='transparent', add=TRUE)
# Sub-regions with at least 1 point
adj3 <- adjacent_ibra(xy, include_type='subregion')
plot(adj3, col='gray80', border='transparent')
# Sub-regions with at least 20 points
adj4 <- adjacent_ibra(xy, include_type='subregion', min_n=20)
plot(adj4, col='gray60', border='transparent', add=TRUE)
# Regions with at least 1 point
adj5 <- adjacent_ibra(xy, include_type='region')
plot(adj5, col='gray80', border='transparent')
# Regions with at least 20 points
adj6 <- adjacent_ibra(xy, min_n=20, include_type='region')
plot(adj6, col='gray60', border='transparent', add=TRUE)
# With plot_output=TRUE
adj7 <- adjacent_ibra(xy, plot_output=TRUE)
# Compare include_type and expand_type
apply(expand.grid(c('polygon', 'subregion', 'region'),
c('polygon', 'subregion', 'region')), 1,
function(x) {
adjacent_ibra(xy, include_type=x[1], expand_type=x[2], plot=TRUE)
title(main=sprintf('include type: %s; expand type: %s', x[1], x[2]))
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.