filterByLand: Filter occurrences based on land vs ocean

View source: R/filterByLand.R

filterByLandR Documentation

Filter occurrences based on land vs ocean

Description

Identifies occurrence records that do not occur on land.

Usage

filterByLand(coords, crs = 4326)

Arguments

coords

coordinates in the form of a 2 column numeric matrix, data.frame, numeric vector, or spatial points object (sf or sp). If spatial object, crs must be defined.

crs

crs of input coords. Ignored if input coords are spatial object.

Details

This function uses a rasterized version of the GSHHG (global self-consistent, hierarchical, high-resolution geography database, https://www.soest.hawaii.edu/pwessel/gshhg/), that has been buffered by 2 km.

Value

returns a logical vector where TRUE means the point falls on land.

Author(s)

Pascal Title

Examples


data(crotalus)

#identify points that fall off land
filterByLand(crotalus[,c('decimallongitude','decimallatitude')])


# testing different input options
samp <- sample(1:nrow(crotalus), 10)
xy <- crotalus[samp, c('decimallongitude', 'decimallatitude')]
sfpts <- sf::st_as_sf(xy, coords = c('decimallongitude', 'decimallatitude'), crs = 4326)
sfptsEA <- sf::st_transform(sfpts, crs = '+proj=eqearth')
spPts <- as(sfpts, 'Spatial')
filterByLand(xy)
filterByLand(sfpts)
filterByLand(sfptsEA)
filterByLand(spPts)


rangeBuilder documentation built on March 7, 2023, 5:30 p.m.