Get Convex Hull Polygons for Species from GBIF Data
get_range_convex_hulls.Rd
Retrieves occurrence data for species from GBIF, clusters spatial points using DBSCAN, and generates convex hull polygons for each cluster.
Usage
get_range_convex_hulls(
data_frame,
species_col = "species_name",
species_name = NULL,
num_cores = 1,
min_points = 5,
min_distance = 1,
gbif_limit = 2000
)
Arguments
- data_frame
A dataframe containing scientific names of species. Must include a column named
species_name
.- species_col
Character string specifying the column in
data_frame
that contains species names. Default is"species_name"
.- species_name
An optional character vector of species names to process. Default is NULL. If
NULL
, all species in the dataframe are processed.- num_cores
The number of cores to use for parallel processing. Default is 1 (no parallel processing).
- min_points
The minimum number of points required to form a range cluster. Default is 5.
- min_distance
The minimum distance between points in a range cluster. Default is 1 epsilon (eps).
- gbif_limit
The maximum number of GBIF records to retrieve per species. Default is 2000.
Value
A named list where each element corresponds to a species and contains a list of sf
polygon objects representing convex hulls.
Details
The function:
Retrieves occurrence records from GBIF using
rgbif::occ_search()
.Filters and cleans records (removing invalid coordinates, duplicates, and certain basis of record types).
Clusters spatial points using
dbscan::dbscan()
witheps = min_distance
andminPts = min_points
.Computes convex hull polygons for each cluster using
sf::st_convex_hull()
.
Parallelization is handled via parallel::mclapply()
when num_cores > 1
.
Examples
# Generate a test dataframe with species Abies cephalonica
if (FALSE) { # \dontrun{
test_data <- data.frame(species_name = c("Abies_cephalonica"))
# Retrieve the unclipped range polygons
unclipped_hulls <- get_range_convex_hulls(test_data)
print(unclipped_hulls)
} # }