Skip to contents

Flags records that fall outside every range polygon of their species, for example an IUCN range map. The polygons come from gazetteers = list(range = <sf>): an sf object with a species column (named like the record's species column, species, binomial or sci_name). Species without a polygon are not tested. With buffers = list(range = m), records within m metres of a polygon edge count as inside.

Usage

clean_range(x, ranges, buffer = 0, ...)

Arguments

x

A data frame of occurrence records.

ranges

Species range polygons, as gazetteers = list(range = ...) in flag_occurrences().

buffer

Buffer distance of the test, in the unit of its Buffer section; the default is the test's default buffer.

...

Further arguments to flag_occurrences(): columns, reference, gazetteers, land_scale.

Value

clean_<test>(): the rows of x the test does not flag, with the columns of x unchanged. See keep_unflagged(), Cleaning functions.

Fields

lon, lat, species.

Buffer

buffers = list(range = 0), in metres. The distance to an edge is measured on the ellipsoid from the closest point of the edge in a local equirectangular projection.

Custom gazetteer

required; there is no shipped range layer.

CoordinateCleaner

Equivalent to cc_iucn(); identical flags without a buffer. With a buffer CoordinateCleaner buffers the polygons with terra, so records very close to the buffer edge may differ.

Examples

if (requireNamespace("sf", quietly = TRUE)) {
  rg <- sf::st_sf(species = "a", geometry = sf::st_sfc(sf::st_polygon(list(
    rbind(c(0, 40), c(20, 40), c(20, 55), c(0, 55), c(0, 40)))), crs = 4326))
  x <- data.frame(species = c("a", "a", "b"), decimalLongitude = c(10, 30, 30),
                  decimalLatitude = 50)
  flag_occurrences(x, tests = "range", gazetteers = list(range = rg))$flag_range
  clean_range(x, ranges = rg)
}