```{asis, echo = {{penvs_bgExtent_knit}}, eval = {{penvs_bgExtent_knit}}, include = {{penvs_bgExtent_knit}}}

Process environmental data

Sampling of {{bgPtsNum_rmd}} background points and corresponding environmental data using a "{{bgSel_rmd}}" method with a {{bgBuf_rmd}} degree buffer.

```r}, include = {{penvs_bgExtent_knit}}}
# Generate background extent 
bgExt_{{spAbr}} <- penvs_bgExtent(
  occs = occs_{{spAbr}},
  bgSel = "{{bgSel_rmd}}",
  bgBuf = {{bgBuf_rmd}})
# Mask environmental data to provided extent
bgMask_{{spAbr}} <- penvs_bgMask(
  occs = occs_{{spAbr}},
  envs = envs_{{spAbr}},
  bgExt = bgExt_{{spAbr}})
# Sample background points from the provided area
bgSample_{{spAbr}} <- penvs_bgSample(
  occs = occs_{{spAbr}},
  bgMask =  bgMask_{{spAbr}},
  bgPtsNum = {{bgPtsNum_rmd}})
# Extract values of environmental layers for each background point
bgEnvsVals_{{spAbr}} <- as.data.frame(raster::extract(bgMask_{{spAbr}},  bgSample_{{spAbr}}))
##Add extracted values to background points table
bgEnvsVals_{{spAbr}} <- cbind(scientific_name = paste0("bg_", "{{spName}}"), bgSample_{{spAbr}},
                            occID = NA, year = NA, institution_code = NA, country = NA,
                            state_province = NA, locality = NA, elevation = NA,
                            record_type = NA, bgEnvsVals_{{spAbr}})


Try the wallace package in your browser

Any scripts or data that you put into this service are public.

wallace documentation built on Sept. 11, 2024, 9:16 p.m.