verifyRasterNames {envirem} | R Documentation |
Verify Raster Names
Description
Given a SpatRaster, this function will verify the naming scheme and check that all required rasters are present.
Usage
verifyRasterNames(
masterstack = NULL,
solradstack = NULL,
monthPET = NULL,
returnRasters = FALSE
)
Arguments
masterstack |
SpatRaster containing all precipitation, min temperature, max temperature, and (optionally) mean temperature variables. |
solradstack |
SpatRaster of monthly solar radiation |
monthPET |
SpatRaster of monthly potential evapotranspiration |
returnRasters |
if |
Details
This function checks that the following are present:
12 precipitation rasters
12 min temperature rasters
12 max temperature rasters
12 mean temperature rasters [optional]
12 solar radiation rasters
12 PET rasters [optional]
The naming scheme will be checked against the one
defined via the custom naming environment. See link{?assignNames}
for additional details.
The function can test the temp/precip SpatRaster and/or the solar radiation SpatRaster separately, or simultaneously.
Value
Prints messages to the console if returnRasters = FALSE
,
If returnRasters = TRUE
, then a SpatRaster is returned. This SpatRaster
will not include rasters that were deemed unnecessary.
Author(s)
Pascal Title
Examples
# Find example rasters
rasterFiles <- list.files(system.file('extdata', package='envirem'), full.names=TRUE)
# create stack of temperature and precipitation rasters
# and stack of solar radiation rasters
solradFiles <- grep('solrad', rasterFiles, value=TRUE)
worldclim <- rast(setdiff(rasterFiles, solradFiles))
solar <- rast(solradFiles)
# modify naming
names(worldclim) <- gsub('tmin_', 'minTemp', names(worldclim))
names(worldclim) <- paste0(names(worldclim), '_v1.0')
names(solar) <- gsub('et_solrad_', 'solar_', names(solar))
# but don't specify this change
namingScheme()
# Run check
verifyRasterNames(masterstack = worldclim, solradstack = solar, returnRasters = FALSE)
# But if we specify our naming scheme
assignNames(tmin = 'minTemp##_v1.0', tmax = 'tmax_##_v1.0', tmean = 'tmean_##_v1.0',
solrad = 'solar_##', precip = 'prec_##_v1.0')
namingScheme()
verifyRasterNames(masterstack = worldclim, solradstack = solar, returnRasters = FALSE)
# set back to defaults
assignNames(reset = TRUE)