Title: | Useful functions for my modules and packages |
---|---|
Description: | A few functions and wrappers around useful code. |
Authors: | Tati Micheletti |
Maintainer: | Tati Micheletti <[email protected]> |
License: | GPL (>=2) |
Version: | 0.1.1 |
Built: | 2024-10-27 04:37:33 UTC |
Source: | https://github.com/PredictiveEcology/usefulFuns |
Compare two or more scenarios for averages through time
avrgTimeComparison( ..., upload, outputFolder, comparisonID, folderID, plotCI = TRUE )
avrgTimeComparison( ..., upload, outputFolder, comparisonID, folderID, plotCI = TRUE )
... |
List or tables of results coming from |
upload |
logical. Should the raster be uploaded to Google Drive? Only works if the raster exists OR is set to be written. |
outputFolder |
character. Path to the folder where it should be saved. |
comparisonID |
character. Name to identify the comparison (for file name) |
folderID |
character. Google folder id to upload to.
Only needs to be provided if |
plotCI |
logical. Should the plot have confidence interval? |
list of significant species or scenarios with indication of increasing or decreasing
Tati Micheletti
Creates a GIF of biomass change
biomassPerSpeciesYearGIF(dataPath, years = NULL, uploadTo)
biomassPerSpeciesYearGIF(dataPath, years = NULL, uploadTo)
dataPath |
character. Path to data |
years |
numeric. Years available/intended to be used for the animated gif. |
uploadTo |
character. Google drive folder id. (i.e. |
list of plots
Tati Micheletti
Creates a GIF of total biomass change
biomassYearGIF(dataPath, years = NULL, uploadTo)
biomassYearGIF(dataPath, years = NULL, uploadTo)
dataPath |
character. Path to data. |
years |
numeric. Years available/intended to be used for the animated gif. |
uploadTo |
character. Google drive folder id. (i.e. |
RasterStack
Tati Micheletti
Bootstrap rasters for testing significance on comparable rasters of different species or scenarios
bootstrapPercentChanges( dataPath, years = c(2001, 2100), sampleSize = "auto", n = 100, shp = NULL, species = NULL, useFuture = FALSE )
bootstrapPercentChanges( dataPath, years = c(2001, 2100), sampleSize = "auto", n = 100, shp = NULL, species = NULL, useFuture = FALSE )
dataPath |
character. Path to raster data. |
years |
numeric. Years to compare. Currently this function only compares 2 years. |
sampleSize |
numeric or "auto" (default). What is the sample size (i.e. number of pixels) we want to use on the bootstrapping? If "auto" it calculates internally Cohen's D And Hedges G Effect Size. |
n |
numeric. Default is 100. How many iterations (random selection of |
shp |
character or shapefile. If you wish to calculate these metrics for separate areas. Needs to match the rasters. Default is NULL (i.e. the whole raster is only one area) |
species |
character. Default is NULL. Which species should this function be ran ? |
useFuture |
logical. Should use future to parallelize?
Requires |
list of significant species or scenarios with indication of increasing or decreasing
Tati Micheletti
Bring objects that represent time series into a list
bringObjectTS(path, rastersNamePattern)
bringObjectTS(path, rastersNamePattern)
path |
path to the directory containing the files to be brought as list. |
rastersNamePattern |
Character vector of the name pattern to be used for the search. |
A list of the objects that were read from disk. Currently the
function only works with .tif
(i.e. raster) and .rds
objects.
Tati Micheletti
Uses a set of rules to calculate how many non-NA pixels in a raster follow those rules, using a shapefile to subset those of interest
calculatePixelsInaRule(ras, rule, pol, shp, ...)
calculatePixelsInaRule(ras, rule, pol, shp, ...)
ras |
|
rule |
character string of rule to determine which pixels should be computed |
pol |
numeric. Representation of the polygon of interest in |
shp |
shapefile indicating the different areas to subset the pixels to consider in the calculation |
... |
Additional arguments |
A list of the percent disturbance, total pixels not NA and how many pixels are disturbed according to the rules.
Tati Micheletti
data.frame
s or data.table
sColumn binds a list of data.frame
s or data.table
s
cbindFromList(lst)
cbindFromList(lst)
lst |
List of |
Returns a merged data.table
with unique columns
Tati Micheletti
LandR
by
multiplication of original traits by a specified factorProvides an easy way of modifying species traits table in LandR
by
multiplication of original traits by a specified factor
changeTraits(speciesTable, param, facMult, species)
changeTraits(speciesTable, param, facMult, species)
speciesTable |
|
param |
Character vector of the trait to be modified. |
facMult |
numeric. Factor by which the specified trait should be multiplied. |
species |
character string of the Species for which the trait should be modified |
A data.table
updated with the new parameters.
Tati Micheletti
Returns a data.table
of versions of all packages attached to your current R session, or used in
a simulation - including git commit if a package was installed from e.g., GitHub.
checkPackagesVersions(simList = NULL, filePath = NULL)
checkPackagesVersions(simList = NULL, filePath = NULL)
simList |
|
filePath |
Character string. If passed, the table is written to the specified file path,
as an |
If you don't provide it, the function will return the information regarding your
current R session's information. When running a simulation, it is automatically
be created by the spades()
and attached as the invisible object .packagesVersions
.
Tati Micheletti
Classify wetlands (really!) using the wetlands layer set as input and a either LCC05 or LCC2010
classifyWetlands( LCC, wetLayerInput, pathData, studyArea = NULL, RasterToMatch = NULL )
classifyWetlands( LCC, wetLayerInput, pathData, studyArea = NULL, RasterToMatch = NULL )
LCC |
numeric. |
wetLayerInput |
Which wetland should be used as input (raster with projection).
It was originally designed to work with the DUCKS Unlimited Waterland
layer (30 m) but can work with any water layers that have the following code:
|
pathData |
Where the layers are stored and/or should be saved to |
studyArea |
If the layer should be cropped and masked after classification. Optional. |
RasterToMatch |
raster to match the new layer after classification to. Optional. |
As with archivist::cache
, returns the value of the
function call or the cached version (i.e., the result from a previous call
to this same cached function with identical arguments).
Tati Micheletti
Intended for use within a SpaDES module.
createDynamicLayersRSF( ageMap, biomassMap, biomassMapName, oldBurnTime, oldBurnName, newBurnName, roadDensity, roadDensityName, waterRaster, waterRasterName, RTM ) createStaticLayersRSF( elevation, vrug, LCC, shrubName, herbName, elevationName, vrugName, reclassLCC05, dynamicLayers, RTM, destinationPath )
createDynamicLayersRSF( ageMap, biomassMap, biomassMapName, oldBurnTime, oldBurnName, newBurnName, roadDensity, roadDensityName, waterRaster, waterRasterName, RTM ) createStaticLayersRSF( elevation, vrug, LCC, shrubName, herbName, elevationName, vrugName, reclassLCC05, dynamicLayers, RTM, destinationPath )
ageMap |
|
biomassMap |
|
biomassMapName |
character. Name of the forest biomass layer. |
oldBurnTime |
numeric. Definition of the initial interval considered to be old burn. The end of this time is 20 years later (i.e. 40-60 years). |
oldBurnName |
character. Name of the old burn layer in the model. |
newBurnName |
character. Name of the new burn layer in the model. |
roadDensity |
Anthropogenic disturbance (raster) layer. Currently, road density layer used for both RSF and demographic models. |
roadDensityName |
character. Name of the road Density layer in the model. |
waterRaster |
|
waterRasterName |
character. Name of the water layer in the model. |
RTM |
|
elevation |
|
vrug |
|
LCC |
|
shrubName |
character. Name of the shrub layer in the model. |
herbName |
character. Name of the herb layer in the model. |
elevationName |
character. Name of the elevation layer in the model. |
vrugName |
character. Name of the vrug layer in the model. |
reclassLCC05 |
List with reclassification for LCC05 values (i.e. LCC05 classes that should be classified as shrub or herbs) |
dynamicLayers |
|
destinationPath |
TODO |
RasterStack
of layers
RasterStack
Tati Micheletti
data.frame
(or data.table
), bootstrapping a
set of covariates around the standard error present in the table.Write an equation based on a data.frame
(or data.table
), bootstrapping a
set of covariates around the standard error present in the table.
createEquation(model, replicates = 100)
createEquation(model, replicates = 100)
model |
|
replicates |
numeric. Number of repetitions to be added to the bootstrapping. |
As with archivist::cache
, returns the value of the
function call or the cached version (i.e., the result from a previous call
to this same cached function with identical arguments).
Tati Micheletti
Uses createEquation
internally.
createModels(caribouCoefTable = NULL, modelsToUse = "M3")
createModels(caribouCoefTable = NULL, modelsToUse = "M3")
caribouCoefTable |
|
modelsToUse |
Character string of the model to be used. Currently only |
named list of the quote of the model that can be parsed to generate the simulated data bootstrapped using the model coefficients.
Tati Micheletti
Check a simList
for a specific object at a specific time, or
searches for it in an input folder (i.e. saved outputs).
Simulates the existence of a simList
with specific objects in time t
.
createModObject(data, sim = NULL, pathInput, currentTime, fun = readRDS)
createModObject(data, sim = NULL, pathInput, currentTime, fun = readRDS)
data |
character string of the object or file name to be searched for |
sim |
|
pathInput |
path to the directory containing the files to be searched for. |
currentTime |
Numeric. Current time to be used to search for the object. |
fun |
function to be used to recover the file. Default is |
A list of the objects that were read from disk. Currently the
function only works with .tif
(i.e. raster) and .rds
objects.
Tati Micheletti
Creates the necessary shrub or herb layers for predictive caribou RSF module.
createShrubHerbLayers( landCoverECCC, reclassLCC05, layerName, includeCrops = FALSE )
createShrubHerbLayers( landCoverECCC, reclassLCC05, layerName, includeCrops = FALSE )
landCoverECCC |
|
reclassLCC05 |
List with reclassification for LCC05 values (i.e. LCC05 classes that should be classified as shrub or herbs) |
layerName |
character. Name of the shrub layer in the model. |
includeCrops |
Logical. Should this layer include crops? |
RasterLayer
of herbs or shrubs
Tati Micheletti
Downloads, reprojects, crops and masks to specific areas in Canada such as: boreal, random areas, provinces and territories, or any of the last in the boreal.
defineStudyArea( testArea = NULL, specificTestArea = NULL, mapSubset = NULL, destinationFolder = tempdir() )
defineStudyArea( testArea = NULL, specificTestArea = NULL, mapSubset = NULL, destinationFolder = tempdir() )
testArea |
Logical. Indicates if the test area should
be anything other than |
specificTestArea |
A character string with a province or territory name, or |
mapSubset |
If |
destinationFolder |
Path to where to save downloaded files. Default is |
Tati Micheletti
## rp is the whole North American boreal region rp <- defineStudyArea(testArea = TRUE, specificTestArea = "boreal", mapSubset = NULL) ## Alberta rp <- defineStudyArea(testArea = TRUE, specificTestArea = "Alberta", mapSubset = NULL) ## Alberta inside boreal extension rp <- defineStudyArea(testArea = TRUE, specificTestArea = "boreal", mapSubset = "Alberta")
## rp is the whole North American boreal region rp <- defineStudyArea(testArea = TRUE, specificTestArea = "boreal", mapSubset = NULL) ## Alberta rp <- defineStudyArea(testArea = TRUE, specificTestArea = "Alberta", mapSubset = NULL) ## Alberta inside boreal extension rp <- defineStudyArea(testArea = TRUE, specificTestArea = "boreal", mapSubset = "Alberta")
Extract disturbance of anthropogenic and fire
extractDisturbanceFast( ageMap, caribouShapefile, recoveryTime = 40, anthropogenicLayer = NULL, waterRaster, rasterToMatch, destinationPath )
extractDisturbanceFast( ageMap, caribouShapefile, recoveryTime = 40, anthropogenicLayer = NULL, waterRaster, rasterToMatch, destinationPath )
ageMap |
|
caribouShapefile |
Shapefile with polygons for which we want to calculate lambda for the caribou demographic model. |
recoveryTime |
numeric. Recovery time in years that the forest needs to support Caribou. Default = 40. |
anthropogenicLayer |
Anthropogenic disturbance (raster) layer. Currently, road density layer used for both RSF and demographic models. |
waterRaster |
|
rasterToMatch |
|
destinationPath |
TODO |
A list of the anthropogenic and fire disturbances as percent (0-100)
Tati Micheletti
Plots of forest age
forestAgePlot( dataPath, typeSim, addCaribousuitability = FALSE, overwrite = FALSE )
forestAgePlot( dataPath, typeSim, addCaribousuitability = FALSE, overwrite = FALSE )
dataPath |
character. Path to data |
typeSim |
character. Which simulation is it? i.e., |
addCaribousuitability |
logical. Should the plot show which forest ages are better or worse for Caribou in a colour-coded way? |
overwrite |
logical. |
plot
Tati Micheletti
caribouPopGrowth
and caribouRSF
.Get the necessary layers for predictive modules such as caribouPopGrowth
and caribouRSF
.
getLayers( currentTime, cohortData, pixelGroupMap, startTime, endTime, recoveryTime = 40, listSACaribou, anthropogenicLayer, roadDensity, waterRaster, isRSF = FALSE, decidousSp = NULL, oldBurnTime = NULL, elevation = NULL, vrug = NULL, LCC05 = NULL, reclassLCC05 = NULL, rasterToMatch = NULL, destinationPath )
getLayers( currentTime, cohortData, pixelGroupMap, startTime, endTime, recoveryTime = 40, listSACaribou, anthropogenicLayer, roadDensity, waterRaster, isRSF = FALSE, decidousSp = NULL, oldBurnTime = NULL, elevation = NULL, vrug = NULL, LCC05 = NULL, reclassLCC05 = NULL, rasterToMatch = NULL, destinationPath )
currentTime |
numeric. Current time being used (i.e. |
cohortData |
|
pixelGroupMap |
raster to identify the |
startTime |
numeric. start time of the simulation. Needed to verify and potentially adjust relative simulation times. |
endTime |
numeric. end time of the simulation. Needed to verify and potentially adjust relative simulation times. |
recoveryTime |
numeric. Recovery time in years that the forest needs to support Caribou. Default = 40. |
listSACaribou |
list of shapefiles with polygons for which we want to calculate lambda for the caribou demographic model. |
anthropogenicLayer |
Anthropogenic disturbance (raster) layer. Currently, 500 m buffered anthropogenic disturbance for demographic models. |
roadDensity |
Anthropogenic disturbance (raster) layer. Currently, road density layer used for RSF models. |
waterRaster |
|
isRSF |
logical. Identify if it should get the layers for the RSF or demographic model. |
decidousSp |
binary raster layer indicating if the dominant biomass in a pixel belongs to a deciduous species. |
oldBurnTime |
numeric. Definition of the initial interval considered to be old burn. The end of this time is 20 years later (i.e. 40-60 years). |
elevation |
|
vrug |
|
LCC05 |
|
reclassLCC05 |
List with reclassification for LCC05 values (i.e. LCC05 classes that should be classified as shrub or herbs) |
rasterToMatch |
|
destinationPath |
TODO |
TODO
Tati Micheletti
Works similarly to grepl
, but for multiple patterns and returning the object.
grepMulti(x, patterns, unwanted = NULL)
grepMulti(x, patterns, unwanted = NULL)
x |
object where to look for patterns. |
patterns |
Character vector of patterns to look for objects. |
unwanted |
Character vector of patterns to exclude from search. |
The objects with specified patterns combined
Tati Micheletti
Create a matrix to use for reclassification of rasters
makeReclassifyMatrix(table, originalCol, reclassifiedTo)
makeReclassifyMatrix(table, originalCol, reclassifiedTo)
table |
|
originalCol |
character. Column in the table that identifies the original classification. |
reclassifiedTo |
character. Column in the table that identifies the desired classification. |
Matrix to use for reclassification of rasters
Tati Micheletti
Calculates the mean value of rasters through time
meanValuesTime(ras, scenario, initialTime)
meanValuesTime(ras, scenario, initialTime)
ras |
|
scenario |
character. Which scenario are you running i.e., |
initialTime |
numeric. Format of the first year of analysis. |
table with average
, SD
and CI95%
Tati Micheletti
Show the modules that have stickers available
modulesAvailable()
modulesAvailable()
A character vector of all modules that have stickers available.
Tati Micheletti
SpaDES
modulesFunction to create stickers for SpaDES
modules
moduleSticker( moduleTable = NULL, moduleName, directory = getwd(), useCache = NULL, savedSticker = NULL, ... )
moduleSticker( moduleTable = NULL, moduleName, directory = getwd(), useCache = NULL, savedSticker = NULL, ... )
moduleTable |
Table with the information to generate the sticker (i.e. figure name, height, colours, etc) |
moduleName |
character string of the module's name. |
directory |
character string of the directory where the sticker should be saved |
useCache |
logical. Should the process of downloading and loading the table be cached? |
savedSticker |
Character string. Name of the file to be saved. If not provided, saves with the name of the figure. Useful if more than one stickers have the same figure |
... |
Other parameters for |
This function returns the location where the sticker is available
Tati Micheletti
postProcess
it using RTM, and brings it to memoryName a raster, postProcess
it using RTM, and brings it to memory
nameAndBringOn(ras, name, RTM = NULL)
nameAndBringOn(ras, name, RTM = NULL)
ras |
|
name |
character. Name of the raster layer. |
RTM |
|
RasterStack
Tati Micheletti
Plots summary of burns
plotBurnSummary( dataPath, typeSim, lastYear, theObject = NULL, overwrite = FALSE )
plotBurnSummary( dataPath, typeSim, lastYear, theObject = NULL, overwrite = FALSE )
dataPath |
character. Path to data |
typeSim |
character. Which simulation is it? i.e., |
lastYear |
TODO |
theObject |
TODO |
overwrite |
logical. Default FALSE |
plot
Tati Micheletti
cohortData
and pixelGroupMap
Plots Leading Vegetation Type using cohortData
and pixelGroupMap
plotLeadingVegetationType( dataPath, typeSim, colNA = "grey85", saveRAS = TRUE, overwrite = FALSE )
plotLeadingVegetationType( dataPath, typeSim, colNA = "grey85", saveRAS = TRUE, overwrite = FALSE )
dataPath |
character. Path to data |
typeSim |
character. Which simulation is it? i.e. |
colNA |
character. The colour to use for |
saveRAS |
logical. Save the raster for posterior use? |
overwrite |
logical. |
plot
Tati Micheletti
cohortData
and pixelGroupMap
Plots vegetation biomass type using cohortData
and pixelGroupMap
plotVegetationBiomass( years = c(2011, 2100), dataPath, typeSim, colNA = "grey85", saveRAS = TRUE, overwrite = FALSE )
plotVegetationBiomass( years = c(2011, 2100), dataPath, typeSim, colNA = "grey85", saveRAS = TRUE, overwrite = FALSE )
years |
numeric. Years available/intended to be used. |
dataPath |
character. Path to data. |
typeSim |
character. Which simulation is it? i.e., |
colNA |
character. The colour to use for |
saveRAS |
logical. Save the raster for posterior use? |
overwrite |
logical. |
plot
Tati Micheletti
Designed primarily for NWT project, but somewhat flexible.
prepareClimateLayers( pathInputs = NULL, variables = NULL, years = NULL, GDriveFolder = NULL, climateFilePath = NULL, fileResolution = NULL, authEmail = NULL, RCP = NULL, climateModel = NULL, ensemble = NULL, rasterToMatch = NULL, studyArea = NULL, model = NULL, droughtMonths = 4:9, returnCalculatedLayersForFireSense = FALSE, yearsWithClimateProjections = 2011:2100, overwrite = FALSE, overwriteOriginalData = FALSE )
prepareClimateLayers( pathInputs = NULL, variables = NULL, years = NULL, GDriveFolder = NULL, climateFilePath = NULL, fileResolution = NULL, authEmail = NULL, RCP = NULL, climateModel = NULL, ensemble = NULL, rasterToMatch = NULL, studyArea = NULL, model = NULL, droughtMonths = 4:9, returnCalculatedLayersForFireSense = FALSE, yearsWithClimateProjections = 2011:2100, overwrite = FALSE, overwriteOriginalData = FALSE )
pathInputs |
Default |
variables |
Character string of the variables to be used, i.e. |
years |
Character string of the years to use. i.e. |
GDriveFolder |
Character string of the folder in Google Drive to upload the layers to. Handy for shared projects. |
climateFilePath |
Character string of the path to the climate file in google drive
(i.e. |
fileResolution |
Character string of the for naming purposes (i.e. |
authEmail |
Character string of Google email for authentication for non-interactive use. |
RCP |
Character string of RCP to be used (i.e. |
climateModel |
Character string of climate mode to be used (i.e. |
ensemble |
Character string of climate ensemble to be used (i.e. |
rasterToMatch |
|
studyArea |
shapefile of study area |
model |
For naming and shortcut for variables: i.e., |
droughtMonths |
Numeric. Months to calculate Monthly Drought Code (MDC) i.e. |
returnCalculatedLayersForFireSense |
Logical. Should it calculate MDC (TRUE) or return the original variables (FALSE)? Default is FALSE. |
yearsWithClimateProjections |
Numeric. The user can pass the years that have climate
projection in the data. Default to |
overwrite |
logical. Default FALSE. Should the layers be overwritten if exist? |
overwriteOriginalData |
logical. Default FALSE. If changes happen in the original layer
(the one provided in |
A list of all years, with each year being the local path for the raster stack that contains all variables.
Tati Micheletti
Intended to prepare the DUCKS Unlimited Hybrid Wetland v. 2.1 layer for different purposes.
The output is a RasterLayer
cropped and reprojected to the studyArea
, and resampled to the
rasterToMatch
if any of these are provided.
prepInputsLayers_DUCKS( destinationPath, lccLayer = "2005", url = NULL, archive = NULL, targetFile = NULL, studyArea = NULL, rasterToMatch = NULL, overwrite = TRUE )
prepInputsLayers_DUCKS( destinationPath, lccLayer = "2005", url = NULL, archive = NULL, targetFile = NULL, studyArea = NULL, rasterToMatch = NULL, overwrite = TRUE )
destinationPath |
Path where to save the downloaded file. |
lccLayer |
Which year should be used as a base for the vegetation layer? Default to 2005 |
url |
The url from where the layer should be downloaded from.
If |
archive |
TODO |
targetFile |
TODO |
studyArea |
Study area for which the layer should be cropped to |
rasterToMatch |
TODO |
overwrite |
Logical indicating whether to overwrite the previously processed file. |
RasterLayer
prepInputs
for a stack of raster layersSimple wrapper around prepInputs
for a stack of raster layers
prepInputStack(...)
prepInputStack(...)
... |
Arguments passed to |
RasterStack
Tati Micheletti
Downloads, reprojects, crops and masks to specific areas in Canada such as: BCR6, random areas, provinces and territories, or any of the last in the BCR6.
provinceBCRStudyArea(bcr = NULL, province = NULL, country, ...)
provinceBCRStudyArea(bcr = NULL, province = NULL, country, ...)
bcr |
Numeric. Bird Conservation Region in North America that you want to crop for.
Default is |
province |
Character string. Province or territory. Default is |
country |
Character string. 3 letter ISO for a specific country. The complete list of
countries can be seen by calling |
... |
Arguments to be passed to |
If you provide a BCR that is outside of a province area, the object returned is NULL
.
Tati Micheletti
Bootstraps rasters for testing significance on comparable rasters of different species or scenarios
reviseSpeciesTraits( speciesTable = NULL, updatedTable = NULL, destinationPath = tempdir(), returnTable = FALSE, species = c("BETU.PAP", "LARI.LAR", "PICE.GLA", "PICE.MAR", "PINU.BAN", "POPU.TRE", "PINU.CON") )
reviseSpeciesTraits( speciesTable = NULL, updatedTable = NULL, destinationPath = tempdir(), returnTable = FALSE, species = c("BETU.PAP", "LARI.LAR", "PICE.GLA", "PICE.MAR", "PINU.BAN", "POPU.TRE", "PINU.CON") )
speciesTable |
|
updatedTable |
|
destinationPath |
character. Where to save the table. Default is |
returnTable |
logical. If TRUE, it uses the ORIGINAL species table traits from LANDIS-II. If FALSE, you have to supply your own table. |
species |
character. Species to update the table for. |
Table of updated tree species traits to be used in LandR biomass simulation
Tati Micheletti
ECCC's RSF plot style
RSFplot( ras, upload = FALSE, writeReclasRas = FALSE, outputFolder = tempdir(), rasName, folderID = NULL )
RSFplot( ras, upload = FALSE, writeReclasRas = FALSE, outputFolder = tempdir(), rasName, folderID = NULL )
ras |
|
upload |
logical. Should the raster be uploaded to Google Drive? Only works if the raster exists OR is set to be written. |
writeReclasRas |
logical. Default is |
outputFolder |
character. Path to the folder where it should be saved. |
rasName |
character. Name of the raster to be saved. |
folderID |
character. Google folder id to upload to.
Only needs to be provided if |
Used for side effects of generating plots that have similar binning system to ECCC's 2011 Caribou RSF, and optionally uploading them to Google Drive.
Tati Micheletti
Get all the values of a raster and remove the NA's, keeping pixel ID.
subsetNonNARas(ras, N = NULL)
subsetNonNARas(ras, N = NULL)
ras |
RasterLayer. |
N |
numeric. If passed, subsets N pixels from the raster. If NULL, returns the whole non-NA raster values. Default is NULL. |
data.table of pixel values and pixel ID
Tati Micheletti
Get a sub-string based on the number of characters and the side to start
substrBoth(strng, howManyCharacters, fromEnd = TRUE)
substrBoth(strng, howManyCharacters, fromEnd = TRUE)
strng |
String from which to grab a subset |
howManyCharacters |
numeric. How many characters should be returned in the sub-string? |
fromEnd |
logical. Default is TRUE. Should the subset start in the end of the string? |
character string of the subset.
Tati Micheletti
Plots biomass per species: proportional or absolute, and total or just overstory
totalBiomassPerSpecies( dataPath, typeSim, proportional = FALSE, columnsType = FALSE, overstory = FALSE, overwrite = FALSE, maxVal = 2e+10 )
totalBiomassPerSpecies( dataPath, typeSim, proportional = FALSE, columnsType = FALSE, overstory = FALSE, overwrite = FALSE, maxVal = 2e+10 )
dataPath |
character. Path to data |
typeSim |
character. Which type of simulation is it? i.e., |
proportional |
logical. Should the plot be of the proportional biomass? |
columnsType |
logical. Should the plot be continuous (lines) or columns? |
overstory |
logical. Should the plot be of the overstory biomass? |
overwrite |
logical. |
maxVal |
numeric. Max value for y axis. Passing this ensures that both overstory
and all biomass plots are comparable Default to |
plot
Tati Micheletti