cc_iucn.RdRemoves or flags records outside of the provided natural range polygon, on a per species basis. Expects one entry per species. See the example or https://www.iucnredlist.org/resources/spatial-data-download for the required polygon structure.
cc_iucn(x, range, lon = "decimallongitude", lat = "decimallatitude", species = "species", buffer = 0, value = "clean", verbose = TRUE)
| x | data.frame. Containing geographical coordinates and species names. |
|---|---|
| range | a SpatialPolygonsDataFrame of natural ranges for species in x.
Must contain a column named as indicated by |
| lon | character string. The column with the longitude coordinates. Default = “decimallongitude”. |
| lat | character string. The column with the latitude coordinates. Default = “decimallatitude”. |
| species | a character string. The column with the species name. Default = “species”. |
| buffer | numerical. The buffer around each species' range, from where records should be flagged as problematic, in decimal degrees. Default = 0. |
| value | character string. Defining the output value. See value. |
| verbose | 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”.
Download natural range maps in suitable format for amphibians, birds, mammals and reptiles from https://www.iucnredlist.org/resources/spatial-data-download. Note: the buffer radius is in degrees, thus will differ slightly between different latitudes.
See https://ropensci.github.io/CoordinateCleaner/ for more details and tutorials.
Other Coordinates: cc_cap,
cc_cen, cc_coun,
cc_dupl, cc_equ,
cc_gbif, cc_inst,
cc_outl, cc_sea,
cc_urb, cc_val,
cc_zero
require(sp)#>x <- data.frame(species = c("A", "B"), decimallongitude = runif(100, -170, 170), decimallatitude = runif(100, -80,80)) range_species_A <- Polygon(cbind(c(-45,-45,-60,-60,-45),c(-10,-25,-25,-10,-10))) range_species_B <- Polygon(cbind(c(15,15,32,32,15),c(10,-10,-10,10,10))) range_A <- Polygons(list(range_species_A), ID = c("A")) range_B <- Polygons(list(range_species_B), ID = c("B")) range <- SpatialPolygons(list(range_A, range_B)) df <- data.frame(species = c("A", "B"), row.names = c("A", "B")) range <- SpatialPolygonsDataFrame(range, data = as.data.frame(df)) cc_iucn(x = x, range = range, buffer = 10)#>#> Warning: no projection information for reference found, #> assuming '+proj=longlat +datum=WGS84 #> +no_defs +ellps=WGS84 +towgs84=0,0,0'#>#> species decimallongitude decimallatitude #> 12 B 22.91815 13.48934 #> 93 A -58.38912 -34.00688