Skip to contents

Join cell_id data from sdm_area to a occurrences

Usage

join_area(occ, pred)

Arguments

occ

A occurrences object or input_sdm.

pred

A sdm_area object to retrieve cell_id from.

Value

A occurrences object with cell_id to each record.

Details

This function is key in this SDM workflow. It attaches cell_id values to occ, deletes records outside pred and allows the use of pseudoabsences. This function also tests if CRS from both occ and pred are equal, otherwise the CRS of pred is used to convert occ.

Author

Luíz Fernando Esser (luizesser@gmail.com) https://luizfesser.wordpress.com

Examples

# Create sdm_area object:
sa <- sdm_area(parana, cell_size = 50000, crs = 6933)
#> ! Making grid over study area is an expensive task. Please, be patient!
#>  Using GDAL to make the grid and resample the variables.

# Include predictors:
sa <- add_predictors(sa, bioc) |> select_predictors(c("bio1", "bio4", "bio12"))
#> ! Making grid over the study area is an expensive task. Please, be patient!
#>  Using GDAL to make the grid and resample the variables.

# Include scenarios:
sa <- add_scenarios(sa, scen)

# Create occurrences:
oc <- occurrences_sdm(occ, crs = 6933) |> join_area(sa)
#> Warning: Some records from `occ` do not fall in `pred`.
#>  3 elements from `occ` were excluded.
#>  If this seems too much, check how `occ` and `pred` intersect.