Creates a data.frame of species' references that contains identifiers of position and species name, using a SpatVector representing multiple species as input.
Arguments
- spdf_object
SpatVector representing species' geographic distributions. The data.frame associated with the object must contain a column named "Species" to distinguish among features.
- spdf_grid
SpatVector of geographic grid for the region of interest (output of function
grid_from_region
).- parallel
(logical) whether to perform analyses in parallel. Default = FALSE.
- n_cores
(numeric) number of cores to be used when
parallel
= TRUE. The default, NULL, uses available cores - 1.
Value
A data.frame of species' found in distinct positions (defined with identifiers); includes two columns: "ID" and "Species".
Examples
# Data
species_data <- terra::vect(system.file("extdata/species_data.gpkg",
package = "biosurvey"))
mx <- terra::vect(system.file("extdata/mx.gpkg", package = "biosurvey"))
# GRID
grid_reg <- grid_from_region(region = mx, cell_size = 100)
# Species data from polygons
sp_data <- spdf_2data(spdf_object = species_data, spdf_grid = grid_reg)
#>
|
| | 0%
|
|=== | 4%
|
|====== | 8%
|
|========= | 12%
|
|============ | 17%
|
|=============== | 21%
|
|================== | 25%
|
|==================== | 29%
|
|======================= | 33%
|
|========================== | 38%
|
|============================= | 42%
|
|================================ | 46%
|
|=================================== | 50%
|
|====================================== | 54%
|
|========================================= | 58%
|
|============================================ | 62%
|
|=============================================== | 67%
|
|================================================== | 71%
|
|==================================================== | 75%
|
|======================================================= | 79%
|
|========================================================== | 83%
|
|============================================================= | 88%
|
|================================================================ | 92%
|
|=================================================================== | 96%
|
|======================================================================| 100%
summary(sp_data)
#> ID Species
#> Min. : 39.0 Length:695
#> 1st Qu.:221.0 Class :character
#> Median :364.0 Mode :character
#> Mean :352.4
#> 3rd Qu.:509.0
#> Max. :658.0