Removes or flags records from inside urban areas, based on a geographic gazetteer. Often records from large databases span substantial time periods (centuries) and old records might represent habitats which today are replaced by city area.
cc_urb(
x,
lon = "decimalLongitude",
lat = "decimalLatitude",
ref = NULL,
value = "clean",
verbose = TRUE
)
data.frame. Containing geographical coordinates and species names.
character string. The column with the longitude coordinates. Default = “decimalLongitude”.
character string. The column with the latitude coordinates. Default = “decimalLatitude”.
a SpatVector. Providing the geographic gazetteer
with the urban areas. See details. By default
rnaturalearth::ne_download(scale = 'medium', type = 'urban_areas',
returnclass = "sf"). Can be any SpatVector
, but the
structure must be identical to rnaturalearth::ne_download()
.
character string. Defining the output value. See value.
logical. If TRUE reports the name of the test and the number of records flagged.
Depending on the ‘value’ argument, either a data.frame
containing the records considered correct by the test (“clean”) or a logical vector (“flagged”), with TRUE = test passed and FALSE = test failed/potentially problematic . Default = “clean”.
See https://ropensci.github.io/CoordinateCleaner/ for more details and tutorials.
if (FALSE) {
x <- data.frame(species = letters[1:10],
decimalLongitude = runif(100, -180, 180),
decimalLatitude = runif(100, -90,90))
cc_urb(x)
cc_urb(x, value = "flagged")
}