View source: R/get_important_rasters.R
prepare_rasters | R Documentation |
This script takes as input a directory of rasters, crops them to the sampling extent, finds the raster values at each sample locality, and uses MAXENT and ENMeval to determine the most important raster layers (i.e. features).
prepare_rasters(
raster.dir,
sample.file,
header = TRUE,
bb.buffer = 10,
plotDIR = "./plots",
showPLOTS = FALSE
)
raster.dir |
Directory of rasters to load and crop |
sample.file |
CSV file with sample information (sampleID,popID,lat,lon) |
header |
Boolean; Does sample.file have a header line? |
bb.buffer |
Integer; Buffer around sample bounding box. bb.buffer = bb.buffer * resolution (in arc-seconds) |
plotDIR |
Directory to save plots to |
showPLOTS |
Boolean; Whether to print plots to screen |
Function to load in and crop the raster layers to the sampling extent
This function takes as input a directory of rasters. Only the desired rasters should be included in raster.dir. You also will need a comma-delimited sample.file that has four columns in a specific order: (sampleIDs,populationIDs,latitude,longitude). You can choose if a header line is present. The rasters will all be put into a stack and cropped to the extent of the sample localities + bb.buffer.
List with cropped rasters and other info
envList <- prepare_rasters(raster.dir = "uncroppedLayers",
sample.file = file.path("exampleData",
"ENMeval_bioclim",
"localityInfo",
"sample_localities_maxent_southeast_noNA.csv"),
header = TRUE,
bb.buffer = 10,
plotDIR = "./plots",
showPLOTS = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.