prepare_rasters: Script to extract raster data for all sampling localities and...

View source: R/get_important_rasters.R

prepare_rastersR Documentation

Script to extract raster data for all sampling localities and find the most important features.

Description

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).

Usage

prepare_rasters(
  raster.dir,
  sample.file,
  header = TRUE,
  bb.buffer = 10,
  plotDIR = "./plots",
  showPLOTS = FALSE
)

Arguments

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

Details

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.

Value

List with cropped rasters and other info

Examples

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)

btmartin721/ClineHelpR documentation built on Oct. 15, 2024, 5:05 a.m.