geographic_filter: Filter points based on distance to other points

Description Usage Arguments Value See Also Examples

View source: R/filter.R

Description

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

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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,]

samuelbosch/marinespeed documentation built on Dec. 17, 2019, 11:47 p.m.