selectbylocation: Select polygon features from another layer and adds polygon...

Description Usage Arguments Value Examples

View source: R/selectbylocation.R

Description

The selectbylocation function selects features based on their location relative to features in another layer.

Usage

1

Arguments

x

source layer of the class SpatialPolygonsDataFrame or SpatialPointsDataFrame

y

Target layer or mask extent to subset from.

Value

A spatial polygons or spatial points object pruned to the extent of the target layer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(raster)
file <- system.file("nigeria/nigeria.rds", package = "phyloregion")
d <- readRDS(file)
e <- extent(d)

set.seed(1)
m <- data.frame(lon = runif(1000, e[1], e[2]),
  lat = runif(1000, e[3], e[4]),
  sites = seq(1000))
coordinates(m) <- ~ lon + lat
z <- selectbylocation(m, d)
plot(d)
points(m, col = "blue", pch = "+")
points(z, col = "red", pch = "+")

phyloregion documentation built on May 1, 2021, 9:06 a.m.