lonLatFilter: Filter lon/lat positions that fall within defined boundaries

View source: R/lonLatFilter.R

lonLatFilterR Documentation

Filter lon/lat positions that fall within defined boundaries

Description

lonLatFilter Tests whether lon/lat positions fall within a defined box of lon/lat borders. Exact matches with southern and western borders are included.

Usage

lonLatFilter(lon_vector, lat_vector, west, east, south, north)

Arguments

lon_vector

Longitude 1 (in decimal degrees)

lat_vector

Latitude 1 (in decimal degrees)

west

West longitude border (decimal degrees)

east

East longitude border (decimal degrees)

south

South latitude border (decimal degrees)

north

North latitude border (decimal degrees)

Value

Vector of position inclusion in the defined lon/lat borders

Examples

set.seed(1)
n <- 1000
Pos <- list(lon=runif(n, min=-180, max=180), lat=runif(n, min=-180, max=180))
# Check to see if positions are withing boundaries
res <- lonLatFilter(Pos$lon, Pos$lat, -20, 20, -40, 40) 
# Plot
op <- par(mar=c(4,4,1,1))
plot(Pos$lon, Pos$lat, pch=21, col=1, bg=2*res)
rect(-20, -40, 20, 40, border=3)
par(op)


marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.