Learn R Programming

rangeBuilder (version 1.6)

filterByProximity: Filter by proximity

Description

Filter occurrence records by their proximity to each other.

Usage

filterByProximity(xy, dist, mapUnits = FALSE, returnIndex = FALSE)

Value

If returnIndex = TRUE, returns a numeric vector of indices. If returnIndex = FALSE, returns coordinates of the same class as the input.

Arguments

xy

longitude and latitude in decimal degrees, either as class matrix, SpatialPoints or SpatialPointsDataFrame.

dist

minimum allowed distance

mapUnits

if TRUE, distance is interpreted in map units, distance in kilometers if FALSE

returnIndex

if TRUE, will return indices of points that would be dropped, if FALSE, returns the points that satisfy the distance filter.

Author

Pascal Title

Details

This function will discard coordinates that fall within a certain distance from other points.

Examples

Run this code

data(crotalus)

# within the first 100 points in the dataset, identify the set of points to 
# drop in order to have points no closer to each other than 20 km

subset <- crotalus[1:100,]
tooClose <- filterByProximity(xy= subset[ ,c('decimallongitude','decimallatitude')], 
	dist=20, mapUnits = FALSE, returnIndex = TRUE)

plot(subset[ ,c('decimallongitude','decimallatitude')], pch=1, col='blue', cex=1.5)
points(subset[tooClose, c('decimallongitude','decimallatitude')], pch=20, col='red')

Run the code above in your browser using DataLab