# 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 <- stack(setdiff(rasterFiles, solradFiles))
solar <- stack(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
varnames()
# 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')
varnames()
verifyRasterNames(masterstack = worldclim, solradstack = solar, returnRasters = FALSE)
# set back to defaults
assignNames(reset = TRUE)
Run the code above in your browser using DataLab