Learn R Programming

marinespeed (version 0.1.0)

geographic_filter: Filter points based on distance to other points

Description

geographic_filter returns the indexes of all points in data that are not within bufferdistance of the filter_data.

Usage

geographic_filter(data, filter_data, buffer_distance = 200*1000,
  lonlat = TRUE)

Arguments

data
Matrix or dataframe. The first two columns should represent the longitude and latitude (or x,y coordinates if lonlat = FALSE).
filter_data
Matrix or dataframe. The first two columns should represent the longitude and latitude (or x,y coordinates if lonlat = FALSE).
buffer_distance
Positive numeric. The minimal distance a point in data should be from a point in filter_data.
lonlat
Logical. If TRUE (default) then Great Circle distances are calculated else Euclidean (planar) distances are calculated.

Value

Vector of integer with the indexes of the rows in data that are not within bufferdistance of the filter_data.

See Also

kfold_occurrence_background

Examples

Run this code
set.seed(42)
data <- cbind(runif(10, -180, 180), runif(10, -90, 90))
filter_data <- cbind(runif(10, -180, 180), runif(10, -90, 90))
# remove points from data data are within a 1000km buffer around
# the points in filter_data
filtered <- geographic_filter(data, filter_data, buffer_distance = 1000*1000,
                              lonlat = TRUE)

data_filtered <- data[filtered,]
data_removed <- data[-filtered,]

Run the code above in your browser using DataLab