├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ ├── pkgdown.yaml │ └── test-coverage.yaml ├── .gitignore ├── .lintr ├── DESCRIPTION ├── LICENSE ├── LandR.Rproj ├── NAMESPACE ├── NEWS.md ├── R ├── LANDIS-II-tables.R ├── LandR-package.R ├── assertions.R ├── biomodWrappers.R ├── biosim.R ├── chooseName.R ├── cohorts.R ├── convertUnwantedLCC2.R ├── dem.R ├── disturbances.R ├── ecoregions.R ├── ecozones.R ├── fireSeverity.R ├── light-shade.R ├── makeDummyInputs.R ├── maps.R ├── maxBestimation.R ├── misc.R ├── nullClimate.R ├── overlayLCCs.R ├── partitionBiomass.R ├── plot_summaries.R ├── plotting.R ├── prepEcoregions.R ├── prepInputObjects.R ├── prepInputs_NTEMS.R ├── prepSpeciesLayers.R ├── seedDispersalLANDIS.R ├── serotiny-resprouting.R ├── speciesPresentFromKNN.R ├── speciesTable.R ├── sppEquivalencies_CA.R ├── sppHarmonize.R ├── studyArea.R ├── terra-raster-utils.R ├── wildfire.R └── zzz.R ├── README.md ├── _pkgdown.yml ├── codecov.yml ├── data-raw ├── sppEquivalencies_CA.R └── sppEquivalencies_CA.csv ├── data └── sppEquivalencies_CA.rda ├── inst └── WORDLIST ├── man-roxygen ├── FireDisturbance.R ├── Nreps.R ├── burnedPixelCohortData.R ├── cacheTags.R ├── calibrate.R ├── cohortData.R ├── cohortDefinitionCols.R ├── colsForPixelGroups.R ├── currentTime.R ├── destinationPath.R ├── doAssertion.R ├── ecoregionMap.R ├── initialB.R ├── minRelativeB.R ├── newPixelCohortData.R ├── pixelCohortData.R ├── pixelGroupMap.R ├── postFirePixelCohortData.R ├── postFireRegenSummary.R ├── rasterToMatch.R ├── rasterToMatchLarge.R ├── rstLCC.R ├── species.R ├── speciesEcoregion.R ├── speciesLayers.R ├── speciesTable.R ├── sppColorVect.R ├── sppEquiv.R ├── sppEquivCol.R ├── sppNameVector.R ├── standAgeMap.R ├── startTime.R ├── studyArea.R ├── studyAreaName.R ├── successionTimestep.R ├── sufficientLight.R ├── summary_plots.R ├── treedFirePixelTableSinceLastDisp.R ├── vegLeadingProportion.R └── verbose.R ├── man ├── BioSIM_extractPoints.Rd ├── BioSIM_getMPBSLR.Rd ├── BioSIM_getWindAnnual.Rd ├── BioSIM_getWindMonthly.Rd ├── CASFRItoSpRasts.Rd ├── Colors.Rd ├── Disturbances.Rd ├── LANDISDisp.Rd ├── LandR-deprecated.Rd ├── LandR-package.Rd ├── NAcover2zero.Rd ├── WardKernel.Rd ├── addNoPixel2CohortData.Rd ├── addPixels2CohortData.Rd ├── aggregateRasByDT.Rd ├── asInteger.Rd ├── assertPostPartialDist.Rd ├── assertions.Rd ├── assignLightProb.Rd ├── biomodEnsembleFrcstWrapper.Rd ├── biomodEnsembleProjMaps.Rd ├── biomodEnsembleWrapper.Rd ├── biomodModelingWrapper.Rd ├── biomodProjWrapper.Rd ├── calcSeverityB.Rd ├── calcSiteShade.Rd ├── calculateClimateEffect.Rd ├── checkSpeciesTraits.Rd ├── columnsForPixelGroups.Rd ├── compare.Rd ├── convertUnwantedLCC.Rd ├── convertUnwantedLCC2.Rd ├── defineFlammable.Rd ├── describeCohortData.Rd ├── doResprouting.Rd ├── doSerotiny.Rd ├── dot-MLLMaxBPartialPlotData.Rd ├── dot-MLLMaxBplotData.Rd ├── dot-createCohortData.Rd ├── dot-fitNLMwCovariates.Rd ├── dot-getMaxBCoefs.Rd ├── dot-interpolateLightProb.Rd ├── dot-logFloor.Rd ├── dot-overlay.Rd ├── dot-speciesTableColNames.Rd ├── dropTerm.Rd ├── dummy-inputs.Rd ├── ecoregionProducer.Rd ├── equivalentName.Rd ├── extractMaxB.Rd ├── fasterizeFromSp.Rd ├── fitNLMModels.Rd ├── genPGsPostDisturbance.Rd ├── generatePixelGroups.Rd ├── genericExtract.Rd ├── getWildfire_NFI.Rd ├── ggplotMLL_maxB.Rd ├── installBioSIM.Rd ├── landisIIrepo.Rd ├── loadCASFRI.Rd ├── loadkNNSpeciesLayers.Rd ├── makeAndCleanInitialCohortData.Rd ├── makeBiomassMap.Rd ├── makeCohortDataFiles.Rd ├── makeEcoregionDT.Rd ├── makeEcoregionMap.Rd ├── makeMinRelativeB.Rd ├── makePickellStack.Rd ├── makePixelGroupMap.Rd ├── makePixelTable.Rd ├── makeSpeciesEcoregion.Rd ├── mergeSppRaster.Rd ├── minRelativeBDefaults.Rd ├── modifySpeciesAndSpeciesEcoregionTable.Rd ├── nonForestedPixels.Rd ├── overlayLCCs.Rd ├── overlayStacks.Rd ├── partialggplotMLL_maxB.Rd ├── partitionBiomass.Rd ├── pixelFate.Rd ├── pkgEnv.Rd ├── plantNewCohorts.Rd ├── plotLeadingSpecies.Rd ├── plotSpatial.Rd ├── plotVTM.Rd ├── prepEcoregions.Rd ├── prepEcozonesRst.Rd ├── prepInputsCanDEM.Rd ├── prepInputsEcoregion.Rd ├── prepInputsFireYear.Rd ├── prepInputsLCC.Rd ├── prepInputsSpecies.Rd ├── prepInputsSpeciesEcoregion.Rd ├── prepInputsStandAgeMap.Rd ├── prepInputs_NTEMS_LCC_FAO.Rd ├── prepInputs_NTEMS_Nonforest.Rd ├── prepRasterToMatch.Rd ├── prepRawBiomassMap.Rd ├── prepSpeciesLayers.Rd ├── randomStudyArea.Rd ├── rasterRead.Rd ├── rasterTerraHelpers.Rd ├── replaceAgeInFires.Rd ├── resample.Rd ├── rescale.Rd ├── rmMissingCohorts.Rd ├── scheduleDisturbance.Rd ├── speciesEcoregionLatestYear.Rd ├── speciesEcoregionStack.Rd ├── speciesPresent.Rd ├── speciesTable.Rd ├── speciesTableUpdate.Rd ├── sppColors.Rd ├── sppEquivCheck.Rd ├── sppEquivalencies_CA.Rd ├── sppHarmonize.Rd ├── standAgeMapGenerator.Rd ├── statsModel.Rd ├── subsetDT.Rd ├── sumRastersBySpecies.Rd ├── uniqueDefinitions.Rd ├── updateCohortData.Rd ├── updateCohortDataPostHarvest.Rd ├── updateSpeciesTable.Rd ├── vegTypeGenerator.Rd └── vegTypeMapGenerator.Rd └── tests ├── testthat.R └── testthat ├── test-compareRas.R ├── test-loadkNNSpeciesLayers.R ├── test-prepRawBiomassMap.R ├── test-speciesTable.R └── test-wardDispersalFunction.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^\.github$ 2 | ^\.httr-oauth$ 3 | ^\.lintr$ 4 | ^.*\.Rproj$ 5 | ^\.Rproj\.user$ 6 | ^_pkgdown\.yml$ 7 | ^codecov\.yml$ 8 | ^data-raw$ 9 | ^docs$ 10 | ^J4RTmpFile$ 11 | ^LICENSE$ 12 | ^man-roxygen$ 13 | ^\.secret$ 14 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | - development 6 | - LandWeb 7 | pull_request: 8 | branches: 9 | - master 10 | - development 11 | 12 | name: R-CMD-check 13 | 14 | jobs: 15 | R-CMD-check: 16 | if: "!contains(github.event.commits[0].message, '[skip-ci]')" 17 | runs-on: ${{ matrix.config.os }} 18 | 19 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) (nosuggests ${{ matrix.config.nosuggests }}) 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | config: 25 | - {os: macOS-latest, nosuggests: false, r: 'release'} 26 | - {os: windows-latest, nosuggests: false, r: 'devel'} 27 | - {os: windows-latest, nosuggests: false, r: 'release'} 28 | - {os: windows-latest, nosuggests: false, r: 'oldrel'} 29 | - {os: ubuntu-20.04, nosuggests: false, r: 'devel'} 30 | - {os: ubuntu-20.04, nosuggests: false, r: 'release'} 31 | - {os: ubuntu-20.04, nosuggests: true, r: 'release'} 32 | - {os: ubuntu-20.04, nosuggests: false, r: 'oldrel'} 33 | 34 | env: 35 | _R_CHECK_DEPENDS_ONLY_: ${{ matrix.config.nosuggests }} 36 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 37 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 38 | 39 | steps: 40 | - uses: actions/checkout@v4 41 | 42 | - uses: r-lib/actions/setup-pandoc@v2 43 | 44 | - uses: PredictiveEcology/actions/install-spatial-deps@v0.1 45 | 46 | - uses: r-lib/actions/setup-r@v2 47 | with: 48 | extra-repositories: 'https://PredictiveEcology.r-universe.dev/' 49 | Ncpus: 2 50 | r-version: ${{ matrix.config.r }} 51 | use-public-rspm: false 52 | 53 | - uses: r-lib/actions/setup-r-dependencies@v2 54 | with: 55 | extra-packages: | 56 | any::rcmdcheck 57 | any::sf 58 | any::XML 59 | BioSIM=?ignore 60 | fastshp=?ignore 61 | NLMR=?ignore 62 | PredictiveEcology/quickPlot@development 63 | PredictiveEcology/reproducible@development 64 | PredictiveEcology/Require@development 65 | PredictiveEcology/SpaDES.core@development 66 | PredictiveEcology/SpaDES.tools@development 67 | 68 | - name: Install additional package dependencies 69 | run: | 70 | pak::pkg_install("remotes") 71 | remotes::install_github("RNCan/BioSimClient_R") 72 | remotes::install_github("s-u/fastshp") 73 | remotes::install_github("ropensci/NLMR") 74 | shell: Rscript {0} 75 | 76 | - uses: r-lib/actions/check-r-package@v2 77 | with: 78 | upload-snapshots: true 79 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | name: pkgdown 13 | 14 | jobs: 15 | pkgdown: 16 | runs-on: ubuntu-latest 17 | # Only restrict concurrency for non-PR jobs 18 | concurrency: 19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 20 | env: 21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - uses: r-lib/actions/setup-pandoc@v2 26 | 27 | - uses: PredictiveEcology/actions/install-spatial-deps@v0.1 28 | 29 | - uses: r-lib/actions/setup-r@v2 30 | with: 31 | extra-repositories: 'https://PredictiveEcology.r-universe.dev/' 32 | use-public-rspm: false 33 | 34 | - uses: r-lib/actions/setup-r-dependencies@v2 35 | with: 36 | extra-packages: | 37 | any::pkgdown 38 | any::sf 39 | any::XML 40 | local::. 41 | BioSIM=?ignore 42 | fastshp=?ignore 43 | NLMR=?ignore 44 | PredictiveEcology/quickPlot@development 45 | PredictiveEcology/reproducible@development 46 | PredictiveEcology/Require@development 47 | PredictiveEcology/SpaDES.core@development 48 | PredictiveEcology/SpaDES.tools@development 49 | needs: website 50 | 51 | - name: Install additional package dependencies 52 | run: | 53 | pak::pkg_install("remotes") 54 | remotes::install_github("RNCan/BioSimClient_R") 55 | remotes::install_github("ropensci/NLMR") 56 | remotes::install_github("s-u/fastshp") 57 | shell: Rscript {0} 58 | 59 | - name: Build site 60 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 61 | shell: Rscript {0} 62 | 63 | - name: Deploy to GitHub pages 🚀 64 | if: github.event_name != 'pull_request' 65 | uses: JamesIves/github-pages-deploy-action@v4 66 | with: 67 | clean: false 68 | branch: gh-pages 69 | folder: docs 70 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | - development 6 | pull_request: 7 | branches: 8 | - master 9 | - development 10 | 11 | name: test-coverage 12 | 13 | jobs: 14 | test-coverage: 15 | if: "!contains(github.event.commits[0].message, '[skip-ci]')" 16 | runs-on: macOS-latest 17 | env: 18 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | 23 | - uses: r-lib/actions/setup-pandoc@v2 24 | 25 | - uses: PredictiveEcology/actions/install-spatial-deps@v0.1 26 | 27 | - uses: r-lib/actions/setup-r@v2 28 | with: 29 | extra-repositories: 'https://PredictiveEcology.r-universe.dev/' 30 | use-public-rspm: false 31 | 32 | - uses: r-lib/actions/setup-r-dependencies@v2 33 | with: 34 | extra-packages: | 35 | any::covr 36 | any::sf 37 | any::XML 38 | BioSIM=?ignore 39 | fastshp=?ignore 40 | NLMR=?ignore 41 | PredictiveEcology/quickPlot@development 42 | PredictiveEcology/reproducible@development 43 | PredictiveEcology/Require@development 44 | PredictiveEcology/SpaDES.core@development 45 | PredictiveEcology/SpaDES.tools@development 46 | 47 | - name: Install additional package dependencies 48 | run: | 49 | pak::pkg_install("remotes") 50 | remotes::install_github("RNCan/BioSimClient_R") 51 | remotes::install_github("ropensci/NLMR") 52 | remotes::install_github("s-u/fastshp") 53 | shell: Rscript {0} 54 | 55 | - name: Test coverage 56 | run: covr::codecov() 57 | shell: Rscript {0} 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | # Session Data files 5 | .RData 6 | # Example code in package build process 7 | *-Ex.R 8 | # Output files from R CMD build 9 | /*.tar.gz 10 | # Output files from R CMD check 11 | /*.Rcheck/ 12 | # RStudio files 13 | .Rproj.user/ 14 | .Rproj.user 15 | # produced vignettes 16 | vignettes/*.html 17 | vignettes/*.pdf 18 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 19 | .httr-oauth 20 | # knitr and R markdown default cache directories 21 | /*_cache/ 22 | /cache/ 23 | # Temporary files created by R markdown 24 | *.utf8.md 25 | *.knit.md 26 | # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html 27 | rsconnect/ 28 | # Rcpp files 29 | *.dll 30 | *.so 31 | *.o 32 | inputs/ 33 | J4RTmpFile 34 | .secret 35 | -------------------------------------------------------------------------------- /.lintr: -------------------------------------------------------------------------------- 1 | linters: linters_with_defaults( 2 | line_length_linter(100), 3 | object_name_linter("camelCase"), 4 | object_usage_linter = NULL, 5 | return_linter = NULL 6 | ) 7 | -------------------------------------------------------------------------------- /LandR.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageCheckArgs: --as-cran 22 | PackageRoxygenize: rd,collate,namespace,vignette 23 | 24 | UseNativePipeOperator: Yes 25 | 26 | QuitChildProcessesOnExit: Yes 27 | DisableExecuteRprofile: Yes 28 | -------------------------------------------------------------------------------- /R/LandR-package.R: -------------------------------------------------------------------------------- 1 | #' `LandR` package 2 | #' 3 | #' Utilities for 'LandR' suite of landscape simulation models. 4 | #' These models simulate forest vegetation dynamics based on LANDIS-II, and 5 | #' incorporate fire and insect disturbance, as well as other important ecological 6 | #' processes. Models are implemented as 'SpaDES' modules. 7 | #' 8 | #' @section Package options: 9 | #' 10 | #' `LandR` packages use the following [options()] to configure behaviour: 11 | #' 12 | #' - `LandR.assertions`: If `TRUE`, additional code checks are run during function calls. 13 | #' Default `FALSE`. 14 | #' 15 | #' @import methods 16 | #' @name LandR-package 17 | #' @rdname LandR-package 18 | "_PACKAGE" 19 | 20 | ## usethis namespace: start 21 | #' @importFrom crayon blue cyan green magenta red 22 | #' @importFrom data.table as.data.table copy data.table fread is.data.table last melt rbindlist 23 | #' @importFrom data.table set setattr setcolorder setDT setDTthreads setkey setkeyv setnames setorderv 24 | #' @importFrom fpCompare %==% %>>% %<<% 25 | #' @importFrom ggplot2 aes coord_equal coord_sf element_blank element_text facet_wrap 26 | #' @importFrom ggplot2 geom_bar geom_hline geom_line geom_point labs geom_raster geom_ribbon geom_sf 27 | #' @importFrom ggplot2 ggplot guide_legend guides labs 28 | #' @importFrom ggplot2 scale_color_distiller 29 | #' @importFrom ggplot2 scale_fill_distiller scale_fill_manual scale_fill_viridis_c scale_fill_viridis_d 30 | #' @importFrom ggplot2 scale_x_discrete 31 | #' @importFrom ggplot2 stat stat_summary sym theme theme_classic unit 32 | #' @importFrom ggpubr theme_pubr 33 | #' @importFrom ggspatial annotation_north_arrow layer_spatial north_arrow_minimal 34 | #' @importFrom grDevices colorRampPalette dev.off png 35 | #' @importFrom lme4 glmer lmer 36 | #' @importFrom MuMIn r.squaredGLMM 37 | #' @importFrom parallel mclapply 38 | #' @importFrom pemisc factorValues2 termsInData 39 | #' @importFrom quickPlot layerNames numLayers Plot setColors setColors<- 40 | #' @importFrom raster calc deratify dropLayer extension levels NAvalue<- projectExtent 41 | #' @importFrom raster raster rasterOptions ratify reclassify stack unstack 42 | #' @importFrom RColorBrewer brewer.pal brewer.pal.info 43 | #' @importFrom reproducible .prefix .requireNamespace .sortDotsUnderscoreFirst .suffix 44 | #' @importFrom reproducible asPath basename2 Cache cropInputs Filenames fixErrors 45 | #' @importFrom reproducible maxFn messageDF minFn paddedFloatToChar 46 | #' @importFrom reproducible postProcess postProcessTerra prepInputs preProcess projectInputs 47 | #' @importFrom reproducible writeOutputs 48 | #' @importFrom sf as_Spatial st_as_sf st_cast st_coordinates st_intersects st_crs 49 | #' @importFrom sf st_read st_transform st_zm 50 | #' @importFrom sp CRS proj4string SpatialPoints 51 | #' @importFrom SpaDES.tools inRange neutralLandscapeMap randomPolygons rasterizeReduced runifC 52 | #' @importFrom SpaDES.tools spread2 53 | #' @importFrom stats as.formula complete.cases fitted glm na.omit predict quantile runif terms update vcov 54 | #' @importFrom terra app as.int cellFromRowCol cellFromXY classify coltab<- compareGeom 55 | #' @importFrom terra crop crs crs<- ext extract focalMat 56 | #' @importFrom terra intersect is.factor is.int is.points levels mask minmax NAflag<- ncell nlyr 57 | #' @importFrom terra project rast rasterize res rowColFromCell terraOptions values vect 58 | #' @importFrom terra writeRaster xmax xmin ymax ymin xyFromCell 59 | #' @importFrom tidyterra geom_spatraster 60 | #' @importFrom tools file_path_sans_ext 61 | #' @importFrom utils capture.output combn count.fields data getFromNamespace install.packages 62 | #' @importFrom utils str tail untar 63 | ## usethis namespace: end 64 | NULL 65 | -------------------------------------------------------------------------------- /R/convertUnwantedLCC2.R: -------------------------------------------------------------------------------- 1 | utils::globalVariables(c( 2 | "possLCC" 3 | )) 4 | #' Convert Land Cover Classes (LCC) to another value in its neighbourhood 5 | #' 6 | #' This will search around the pixels on `rstLCC` that have 7 | #' `classesToReplace`, and search in iteratively increasing 8 | #' radii outwards for other Land Cover Classes than the those indicated in 9 | #' `classesToReplace`. 10 | #'. 11 | #' @param classesToReplace Integer vector of classes that are are to be replaced, 12 | #' e.g., 34, 35, 36 on LCC2005, which are burned young, burned 10 year, and cities. 13 | #' @template rstLCC 14 | #' @param nIterations the number of iterations to perform 15 | #' @param defaultNewValue the value to assign a pixel in `classesToReplace` if no valid pixel 16 | #' is closer after `nIterations` 17 | #' @param invalidClasses classes that are not valid options 18 | #' 19 | #' 20 | #' 21 | #' @return 22 | #' A `rasterLayer` with values in `classesToReplace` converted to adjacent values or NA. 23 | #' 24 | #' @author Eliot McIntire Ian Eddy 25 | #' @export 26 | convertUnwantedLCC2 <- function(classesToReplace = 34:36, rstLCC, nIterations = 6, defaultNewValue = NA, 27 | invalidClasses = NA) { 28 | 29 | lccDT <- data.table(pixelIndex = 1:ncell(rstLCC), lcc = as.vector(rstLCC)) 30 | 31 | theUnwantedPixels <- lccDT[!is.na(lcc) & lcc %in% classesToReplace]$pixelIndex 32 | # lccShort <- lccDT[pixelIndex %in% theUnwantedPixels] #keep for joining 33 | lccOut <- data.table("pixelIndex" = integer(0), lcc = integer(0), 34 | pixels = integer(0), possLCC = integer(0)) 35 | iterations <- 1 36 | # remove the lines that have the code "classesToReplace" 37 | repeatsOnSameUnwanted <- 0 38 | 39 | while (length(theUnwantedPixels) > 0) { 40 | message("Converting unwanted LCCs: ", length(theUnwantedPixels), " pixels remaining.") 41 | out <- spread2(rstLCC, 42 | start = theUnwantedPixels, asRaster = FALSE, 43 | iterations = iterations, allowOverlap = TRUE, spreadProb = 1 44 | ) 45 | out <- out[initialPixels != pixels] # rm pixels which are same as initialPixels --> these are known wrong 46 | iterations <- iterations + 1 47 | out[, possLCC := rstLCC[][pixels]] 48 | out[possLCC %in% c(classesToReplace, invalidClasses), possLCC := NA] 49 | out <- na.omit(out) 50 | out2 <- lccDT[out[, state := NULL], 51 | allow.cartesian = TRUE, 52 | on = c("pixelIndex" = "initialPixels"), nomatch = NA] 53 | 54 | # sanity check -- don't let an infinite loop 55 | 56 | if (repeatsOnSameUnwanted >= nIterations) { 57 | message( 58 | " reclassifying ", NROW(theUnwantedPixels), " pixels of class ", 59 | paste(unique(rstLCC[theUnwantedPixels]), collapse = ", "), " as class ", defaultNewValue, 60 | " because no suitable replacement was found" 61 | ) 62 | pixelsToNA <- theUnwantedPixels 63 | theUnwantedPixels <- integer() 64 | } 65 | 66 | lccOut <- rbind(out2, lccOut) 67 | 68 | theUnwantedPixels <- theUnwantedPixels[!theUnwantedPixels %in% out2$pixelIndex] 69 | repeatsOnSameUnwanted <- repeatsOnSameUnwanted + 1 70 | } 71 | 72 | ## take random sample of available, weighted by abundance 73 | rowsToKeep <- lccOut[, list(keep = .resample(.I, 1)), by = c("pixelIndex")] 74 | lccOut <- lccOut[rowsToKeep$keep] 75 | rstLCC[lccOut$pixelIndex] <- lccOut$possLCC 76 | rstLCC[pixelsToNA] <- defaultNewValue 77 | 78 | return(rstLCC) 79 | 80 | } 81 | -------------------------------------------------------------------------------- /R/dem.R: -------------------------------------------------------------------------------- 1 | #' Get digital elevation map of Canada 2 | #' 3 | #' Defaults to using 3 arcmin DEM of Canada in lonlat. 4 | #' 5 | #' @template studyArea 6 | #' @template rasterToMatch 7 | #' @template destinationPath 8 | #' 9 | #' @return `RasterLayer` 10 | #' 11 | #' @export 12 | prepInputsCanDEM <- function(studyArea, rasterToMatch, destinationPath) { 13 | dem_url <- "https://drive.google.com/file/d/1Cd4J5I2LHGUJosDQgfKrb_T93ZVSWCkt/" 14 | 15 | lonlat <- CRS("+proj=longlat +datum=WGS84") 16 | studyArea_lonlat <- projectInputs(studyArea, lonlat) 17 | 18 | dem <- prepInputs( 19 | targetFile = "Canada_3ArcMinuteDEM.asc", 20 | url = dem_url, 21 | destinationPath = destinationPath, 22 | fun = "terra::rast", method = "bilinear" 23 | ) 24 | crs(dem) <- lonlat 25 | dem <- postProcess(dem, studyArea = studyArea_lonlat, rasterToMatch = rasterToMatch) 26 | } 27 | -------------------------------------------------------------------------------- /R/ecozones.R: -------------------------------------------------------------------------------- 1 | #' Prepare ecozones raster 2 | #' 3 | #' Download, rasterize, crop, mask, and reproject Canadian national ecozones shapefile. 4 | #' 5 | #' @param url character. ecozones shapefile url. 6 | #' Default: . 7 | #' 8 | #' @template destinationPath 9 | #' 10 | #' @template studyArea 11 | #' 12 | #' @template rasterToMatch 13 | #' 14 | #' @return `RasterLayer` 15 | #' 16 | #' @export 17 | prepEcozonesRst <- function(url, destinationPath, studyArea = NULL, rasterToMatch = NULL) { 18 | if (is.null(url)) { 19 | url <- "http://sis.agr.gc.ca/cansis/nsdb/ecostrat/zone/ecozone_shp.zip" 20 | } 21 | 22 | targetCRS <- NULL 23 | 24 | if (!is.null(rasterToMatch)) { 25 | targetCRS <- proj4string(rasterToMatch) 26 | } 27 | 28 | if (!is.null(studyArea)) { 29 | studyArea <- as_Spatial(studyArea) 30 | targetCRS <- proj4string(studyArea) 31 | } 32 | 33 | ecozone_shp <- prepInputs( 34 | url = url, 35 | targetFile = "ecozones.shp", 36 | alsoExtract = "similar", 37 | fun = "sf::st_read", 38 | destinationPath = destinationPath, 39 | studyArea = studyArea, 40 | targetCRS = targetCRS 41 | ) 42 | 43 | ecozone_shp[["ZONE_NAME"]] <- as.factor(ecozone_shp[["ZONE_NAME"]]) 44 | ecozone <- rasterize(ecozone_shp, rast(rasterToMatch), field = "ZONE_NAME", fun = "sum") 45 | ecozone <- rast(ecozone) 46 | ecozone <- as.int(ecozone) 47 | 48 | if (is(rasterToMatch, "Raster")) { 49 | rasterToMatch <- terra::rast(rasterToMatch) 50 | } 51 | 52 | ecozone <- terra::project(ecozone, rasterToMatch, method = "near") 53 | ecozone <- terra::mask(ecozone, rasterToMatch) 54 | 55 | return(ecozone) 56 | } 57 | -------------------------------------------------------------------------------- /R/fireSeverity.R: -------------------------------------------------------------------------------- 1 | utils::globalVariables(c( 2 | ".", ":=", "B", "pixelGroup", "postfireB", "prefireB", "severityB", "severityPropB", "speciesCode" 3 | )) 4 | 5 | #' Calculate fire severity 6 | #' 7 | #' Calculates fire severity as the loss of pre-fire to 8 | #' post-fire biomass (in absolute and percentual terms). 9 | #' 10 | #' @template cohortData 11 | #' @template burnedPixelCohortData 12 | #' 13 | #' @note if `burnedPixelCohortData` does not have a `B` 14 | #' column, the fire is assumed to be stand replacing (i.e. 15 | #' we assume B to be 0 across all pixels/cohorts in 16 | #' `burnedPixelCohortData`) 17 | #' 18 | #' @export 19 | #' @return `data.table` with columns `pixelIndex`, 20 | #' `pixelGroup` and `severityB` (absolute biomass lost) 21 | #' and `severityPropB` (proportion of biomass lost) 22 | #' 23 | #' 24 | calcSeverityB <- function(cohortData, burnedPixelCohortData) { 25 | ## start with post-fire B - depending on the module used B 26 | ## may be present or not 27 | severityData <- copy(burnedPixelCohortData) 28 | 29 | if (!"B" %in% names(severityData)) { 30 | message("Assuming a stand replacing fire") 31 | severityData[, B := 0] 32 | } 33 | 34 | ## calculate post-fire stand biomass, drop unnecessary columns 35 | severityData <- severityData[, list(postfireB = sum(B), pixelGroup = pixelGroup), by = pixelIndex] |> 36 | unique() 37 | 38 | ## sum initial B to stand level and add to severityData - this expands cohortData's B to pixels. 39 | severityData <- cohortData[, list(prefireB = sum(B)), by = pixelGroup][severityData, on = "pixelGroup"] 40 | 41 | ## calculate severity in terms of absolute biomass lost 42 | severityData[, severityB := prefireB - postfireB] 43 | ## calculate severity in terms of percent biomass lost 44 | severityData[, severityPropB := severityB/prefireB] 45 | 46 | ## drop prefireB and postfireB columns 47 | return(severityData[, .(pixelGroup, pixelIndex, severityB, severityPropB)]) 48 | } 49 | -------------------------------------------------------------------------------- /R/light-shade.R: -------------------------------------------------------------------------------- 1 | utils::globalVariables(c(".", ":=", "X1", "X2", "X3", "X4", "X5", "maxMaxB", "prevMortality")) 2 | 3 | #' Calculate site shade 4 | #' 5 | #' @template currentTime 6 | #' @template cohortData 7 | #' @template speciesEcoregion 8 | #' @template minRelativeB 9 | #' 10 | #' @seealso [makeMinRelativeB()] 11 | #' 12 | #' @return `cohortData` table with a `siteShade` column 13 | #' 14 | #' @export 15 | calcSiteShade <- function(currentTime, cohortData, speciesEcoregion, minRelativeB) { 16 | # the siteshade was calculated based on the code: 17 | # https://github.com/LANDIS-II-Foundation/Extensions-Succession/blob/master/biomass-succession/trunk/src/PlugIn.cs 18 | if (nrow(cohortData[age > 5,]) > 0) { 19 | 20 | bAMterm1 <- cohortData[age > 5, ':='(prevMortality = sum(mortality, na.rm = TRUE), 21 | sumB = asInteger(sum(B, na.rm = TRUE)), 22 | ecoregionGroup = ecoregionGroup), 23 | by = .(pixelGroup)] #had to move ecoregionGroup from 'by' to 'j' to account for EGsinPG 24 | bAMterm1[is.na(sumB), sumB := 0L] 25 | bAMterm1[is.na(prevMortality), prevMortality := 0] 26 | bAMterm1 <- unique(bAMterm1, by = c("pixelGroup", "ecoregionGroup")) 27 | #set(cohortData, NULL, "prevMortality", NULL) 28 | } else { 29 | bAMterm1 <- unique(cohortData, by = c("pixelGroup", "ecoregionGroup"))[ 30 | , .(pixelGroup, ecoregionGroup)][ 31 | , ':='(prevMortality = 0, sumB = 0)] 32 | } 33 | #bAM <- data.table(speciesEcoregion)[year <= time(sim) & (year > (time(sim)-P(sim)$successionTimestep))] 34 | bAM <- speciesEcoregionLatestYear(speciesEcoregion, currentTime) 35 | bAM <- na.omit(bAM) # remove ecoregion-species groups with no maxB or maxANPP 36 | bAM <- bAM[, .(maxMaxB = max(maxB, na.rm = TRUE)), by = ecoregionGroup] 37 | setkey(bAM, ecoregionGroup) 38 | setkey(bAMterm1, ecoregionGroup) 39 | bAMterm1 <- bAM[bAMterm1, nomatch = 0] 40 | bAMterm1[, sumB := asInteger(pmin((maxMaxB - prevMortality), sumB))] 41 | bAMterm1[, bAM := sumB / maxMaxB] 42 | minRelativeB <- data.table(minRelativeB) 43 | setkey(minRelativeB, ecoregionGroup) 44 | bAMterm1 <- minRelativeB[bAMterm1, nomatch = 0] 45 | bAMterm1$bAM <- round(bAMterm1$bAM, 3) 46 | 47 | # This is faster than using cut 48 | bAMterm1[, siteShade := which(bAM < unique(c(0, X1, X2, X3, X4, X5, 1.1)))[1] - 2, 49 | by = .(pixelGroup, ecoregionGroup)] 50 | # b[, siteShade := as.integer(cut(bAM, sort(unique(c(0, X1, X2, X3, X4, X5, 1))), 51 | # labels = FALSE, right = FALSE, include.lowest = TRUE) - 1), 52 | # by = pixelGroup] 53 | # if (!all.equal(b$siteShade, bAMterm1$siteShade)) 54 | # stop("aaaaa") 55 | bAMterm1 <- bAMterm1[, .(pixelGroup, ecoregionGroup, siteShade)] 56 | return(bAMterm1) 57 | } 58 | -------------------------------------------------------------------------------- /R/nullClimate.R: -------------------------------------------------------------------------------- 1 | #' Null climate effect 2 | #' 3 | #' Default climate effects function in the case where no climate effect is simulated 4 | #' 5 | #' @template cohortData 6 | #' @param ... additional arguments that are passed to LandR.CS 7 | #' 8 | #' @details the `cohortData` object is used to calculate the \% 9 | #' reduction/increase of mortality and growth biomasses per cohort. 10 | #' 11 | #' @return `data.table` with `pixelGroup`, `age` and `speciesCode`, as well as 12 | #' `mortPred` and `growthPred` columns with \% reduction/increase of mortality and 13 | #' growth biomasses resulting from a climate effect. 14 | #' These percentages are later multiplied by the by baseline biomasses of mortality and growth 15 | #' (e.g. 0\% meaning total mortality or growth reduction, and 100\% meaning no reduction). 16 | #' This default, no climate effect, function outputs 100\% for all cohorts for both 17 | #' `mortPred` and `growthPred`. 18 | #' 19 | #' @export 20 | calculateClimateEffect <- function(cohortData, ...) { 21 | predObj <- unique(cohortData[, .(pixelGroup, age, speciesCode)]) 22 | predObj[, `:=`(mortPred = 100, growthPred = 100)] 23 | return(predObj) 24 | } 25 | -------------------------------------------------------------------------------- /R/partitionBiomass.R: -------------------------------------------------------------------------------- 1 | utils::globalVariables(c("Broadleaf", "cover", "cover2", "decid", "LandR", "totalBiomass")) 2 | 3 | #' Partition biomass according to cover estimates 4 | #' 5 | #' This function will partition `totalBiomass` into each cohort. 6 | #' It will discount deciduous cover, if `x < 1`. 7 | #' @param x The ratio for deciduous cover:biomass, where conifer cover:biomass = 1 8 | #' @param pixelCohortData A full `pixelCohortData` object (i.e., not `cohortData`) 9 | #' @export 10 | partitionBiomass <- function(x = 1, pixelCohortData) { 11 | if (!"decid" %in% colnames(pixelCohortData)) { 12 | sppEquivalencies_CA <- get(data("sppEquivalencies_CA", package = "LandR", 13 | envir = environment()), inherits = FALSE) 14 | 15 | colName <- equivalentNameColumn(as.character(unique(pixelCohortData$speciesCode)), 16 | sppEquivalencies_CA) 17 | decidSp <- equivalentName(sppEquivalencies_CA[Broadleaf == TRUE, LandR], 18 | sppEquivalencies_CA, colName) 19 | decidSp <- decidSp[nzchar(decidSp)] 20 | pixelCohortData[, decid := speciesCode %in% decidSp] 21 | } 22 | 23 | pixelCohortData[, cover2 := cover * c(1, x)[decid + 1]] 24 | pixelCohortData[, cover2 := cover2 / sum(cover2), by = "pixelIndex"] 25 | pixelCohortData[, B := totalBiomass * cover2] 26 | 27 | set(pixelCohortData, NULL, c("decid", "cover2"), NULL) 28 | 29 | pixelCohortData 30 | } 31 | -------------------------------------------------------------------------------- /R/speciesTable.R: -------------------------------------------------------------------------------- 1 | #' Customize species trait table values 2 | #' 3 | #' @template speciesTable 4 | #' @param params A named list (of parameters) of named lists (by species), with species 5 | #' traits overrides (e.g., `list(seeddistance_eff = list(Abie_sp = 25))`). 6 | #' 7 | #' @author Alex Chubaty and Ceres Barros 8 | #' @export 9 | updateSpeciesTable <- function(speciesTable, params) { 10 | ## checks: 11 | traits <- names(params) 12 | missingTraits <- traits[!traits %in% names(speciesTable)] 13 | if (length(missingTraits)) 14 | stop("The traits: ", paste(missingTraits, collapse = ", "), "\ndo not exist in `speciesTable`") 15 | 16 | for (trt in traits) { 17 | subParams <- params[[trt]] 18 | 19 | ## checks: 20 | spp <- names(subParams) 21 | missingSpp <- spp[!spp %in% speciesTable$species] 22 | if (length(missingSpp)) { 23 | stop("The species: ", paste(missingSpp, collapse = ", "), 24 | "\ndo not exist in `speciesTable$species`") 25 | } 26 | 27 | ## this is sub ideal to convert classes, but the only solution I found. 28 | ## neither class(...) <- class(..) nor as(..., class(...)) were changing integer to numeric. 29 | ## only as.numeric(...) worked 30 | if (class(unlist(subParams)) != class(speciesTable[[trt]])) { 31 | asFUN <- get(paste0("as.", class(unlist(subParams)))) 32 | if (!is.function(asFUN)) 33 | stop("Can't find an `as.` method to convert class to '", class(unlist(subParams)), "'") 34 | 35 | speciesTable <- speciesTable[, (trt) := lapply(.SD, asFUN), .SDcols = trt] 36 | } 37 | 38 | for (sp in spp) { 39 | set(speciesTable, which(speciesTable$species == sp), trt, subParams[[sp]]) 40 | } 41 | } 42 | 43 | return(speciesTable) 44 | } 45 | -------------------------------------------------------------------------------- /R/sppEquivalencies_CA.R: -------------------------------------------------------------------------------- 1 | #' Table of species name equivalencies for Canadian trees 2 | #' 3 | #' A table containing the different species names used across different sources (e.g., LANDIS-II 4 | #' test parameter files and trait tables, the LandR standard, kNN species biomass layers, etc.). 5 | #' Each column refers to a different source or species naming approach. 6 | #' Presently only containing Canadian native tree species, with name equivalencies coming from: 7 | #' \itemize{ 8 | #' \item LANDIS-II test parameter tables (column `LANDIStest_names`; 9 | #' source: ); 10 | #' \item LANDIS-II Canada-wide trait table (column `LANDIStraits_names`; 11 | #' source: ); 12 | #' \item LandR family of SpaDES modules (column `LandR_names`; 13 | #' \item CFS kNN species biomass layers (column `KNN_names`; 14 | #' source: ); 15 | #' \item Canadian Common Attribute Schema for Forest Resource Inventories (column `CASFRI_names`; 16 | #' source ). 17 | #' } 18 | #' 19 | #' Remaining columns have been filled with some other useful ways to name species (e.g., for plotting). 20 | #' 21 | #' This table is currently used as the default equivalencies table in LandR SpaDES modules, 22 | #' but can also serve as a template to customize species names equivalencies by the user. 23 | #' 24 | #' @format A `data.frame` with 271 rows and 10 variables: 25 | #' \describe{ 26 | #' \item{LANDIS_test}{species names from LANDIS-II test parameter table} 27 | #' \item{LANDIS_traits}{species names from LANDIS-II traits parameter table} 28 | #' \item{LandR}{species names from LandR modules} 29 | #' \item{KNN}{species names from kNN datasets} 30 | #' \item{CASFRI}{species names from CASFRI database} 31 | #' \item{Latin_full}{accepted species latin names as in } 32 | #' \item{EN_generic_short}{Short version of species' common names in English} 33 | #' \item{EN_generic_full}{Full species common names in English} 34 | #' \item{Leading}{Simple common English names used for leading species} 35 | #' \item{Notes}{additional notes and information} 36 | #' \item{Boreal}{Species present in the Boreal forests of Canada} 37 | #' \item{Type}{Whether the species is a deciduous or conifer species} 38 | #' \item{PSP}{species name from the module ianmseddy/PSP_Clean} 39 | #' \item{BC_Forestry}{the species code adopted by the Government of British Columbia} 40 | #' \item{FuelClass}{The fuel class used by the module PredictiveEcology/fireSense}#' 41 | #' } 42 | #' 43 | "sppEquivalencies_CA" 44 | -------------------------------------------------------------------------------- /R/studyArea.R: -------------------------------------------------------------------------------- 1 | #' Create default study areas for use with LandR modules 2 | #' 3 | #' This simply re-exports `SpaDES.tools::randomStudyArea` 4 | #' 5 | #' @inheritParams SpaDES.tools::randomStudyArea 6 | #' 7 | #' @export 8 | randomStudyArea <- utils::getFromNamespace("randomStudyArea", "SpaDES.tools") 9 | -------------------------------------------------------------------------------- /R/wildfire.R: -------------------------------------------------------------------------------- 1 | #' Download and prepare raster fire data from NFI 2 | #' 3 | #' @param dPath destination path for archive 4 | #' @template rasterToMatch 5 | #' @param url location from which to download the wildfire raster layer(s) 6 | #' 7 | #' @return a raster with values representing fire year 1985-2015 8 | #' 9 | #' @export 10 | getWildfire_NFI <- function(dPath, rasterToMatch, url = NULL) { 11 | if (!requireNamespace("terra", quietly = TRUE)) { 12 | ## since terra is dependency of raster, it should already be installed, but just in case... 13 | stop("Suggested package 'terra' not installed.\n", 14 | "Install it using `install.packages('terra')`.") 15 | } 16 | 17 | if (is.null(url)) { 18 | url <- paste0("https://opendata.nfis.org/downloads/forest_change/", 19 | "CA_forest_wildfire_year_DNBR_Magnitude_1985_2015.zip") 20 | } 21 | 22 | ## this is an enormous raster - we want the second raster in the stack, wildfire year 23 | fireDL <- preProcess( 24 | url = url, 25 | destinationPath = dPath, 26 | targetFile = raster::extension(basename(url), "tif"), 27 | alsoExtract = "similar" 28 | ) 29 | wildfireYear <- terra::rast(fireDL$targetFilePath) 30 | wildfireYear2 <- wildfireYear$CA_forest_wildfire_year_DNBR_Magnitude_1985_2015_2 ## only need year 31 | 32 | ## TODO: Caching of postProcessTerra() directly is still experimental/inconsistent; avoid for now 33 | wildfire_SA <- postProcessTerra(wildfireYear2, to = rasterToMatch, method = "near") 34 | wildfire_SA[wildfire_SA == 0L] <- NA_integer_ 35 | wildfire_SA <- wildfire_SA + 1900 36 | wildfire_SA <- terra::as.int(wildfire_SA) 37 | 38 | return(wildfire_SA) 39 | } 40 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname, pkgname) { 2 | ## set options using the approach used by devtools 3 | opts <- options() 4 | reproCachePath <- getOption("reproducible.cachePath") 5 | opts.LandR <- list( # nolint 6 | LandR.assertions = TRUE, 7 | LandR.verbose = 1 8 | ) 9 | toset <- !(names(opts.LandR) %in% names(opts)) 10 | if (any(toset)) options(opts.LandR[toset]) 11 | 12 | invisible() 13 | } 14 | 15 | #' The `LandR` package environment 16 | #' 17 | #' Environment used internally to store internal package objects and methods. 18 | #' 19 | #' @keywords internal 20 | #' @rdname pkgEnv 21 | .pkgEnv <- new.env(parent = emptyenv()) 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LandR 2 | 3 | 4 | [![R build status](https://github.com/PredictiveEcology/LandR/workflows/R-CMD-check/badge.svg)](https://github.com/PredictiveEcology/LandR/actions) 5 | [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/LandR)](https://cran.r-project.org/package=LandR) 6 | [![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/LandR)](https://cran.r-project.org/package=LandR) 7 | [![Codecov test coverage](https://codecov.io/gh/PredictiveEcology/LandR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/PredictiveEcology/LandR?branch=master) 8 | 9 | 10 | **Landscape Ecosystem Modelling in R** 11 | 12 | Utilities for 'LandR' suite of landscape simulation models. 13 | These models simulate forest vegetation dynamics based on LANDIS-II, and incorporate fire and insect disturbance, as well as other important ecological processes. 14 | Models are implemented as `SpaDES` modules. 15 | 16 | ## Installation 17 | 18 | ### Current release 19 | 20 | [![R build status](https://github.com/PredictiveEcology/LandR/workflows/R-CMD-check/badge.svg?branch=master)](https://github.com/PredictiveEcology/LandR/actions) 21 | [![Codecov test coverage](https://codecov.io/gh/PredictiveEcology/LandR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/PredictiveEcology/LandR?branch=master) 22 | 23 | **Install from CRAN:** 24 | 25 | ```r 26 | #install.packages("LandR") ## not yet on CRAN 27 | ``` 28 | 29 | **Install from GitHub:** 30 | 31 | ```r 32 | #install.packages("devtools") 33 | library("devtools") 34 | install_github("PredictiveEcology/LandR", dependencies = TRUE) 35 | ``` 36 | 37 | ### Development version 38 | 39 | [![R build status](https://github.com/PredictiveEcology/LandR/workflows/R-CMD-check/badge.svg?branch=development)](https://github.com/PredictiveEcology/LandR/actions) 40 | [![Codecov test coverage](https://codecov.io/gh/PredictiveEcology/LandR/branch/development/graph/badge.svg)](https://app.codecov.io/gh/PredictiveEcology/LandR?branch=development) 41 | 42 | **Install from GitHub:** 43 | 44 | ```r 45 | #install.packages("devtools") 46 | library("devtools") 47 | install_github("PredictiveEcology/LandR", ref = "development", dependencies = TRUE) 48 | ``` 49 | 50 | ## Getting help 51 | 52 | - Bug reports: 53 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://landr.predictiveecology.org 2 | 3 | template: 4 | params: 5 | bootswatch: flatly 6 | ganalytics: UA-58633549-5 7 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /data-raw/sppEquivalencies_CA.R: -------------------------------------------------------------------------------- 1 | library(data.table) 2 | 3 | sppEquivalencies_CA <- fread("data-raw/sppEquivalencies_CA.csv", 4 | stringsAsFactors = FALSE, header = TRUE) 5 | str(sppEquivalencies_CA) 6 | 7 | ## subset kNN species names to existing layers 8 | if (FALSE) { ## run this manually 9 | library(RCurl) 10 | library(XML) 11 | 12 | fileURLs2001 <- getURL(paste0("https://ftp.maps.canada.ca/pub/nrcan_rncan/Forests_Foret/", 13 | "canada-forests-attributes_attributs-forests-canada/", 14 | "2001-attributes_attributs-2001/"), 15 | dirlistonly = TRUE, 16 | .opts = list(followlocation = TRUE)) 17 | fileNames2001 <- getHTMLLinks(fileURLs2001) 18 | 19 | fileURLs2011 <- getURL(paste0("https://ftp.maps.canada.ca/pub/nrcan_rncan/Forests_Foret/", 20 | "canada-forests-attributes_attributs-forests-canada/", 21 | "2011-attributes_attributs-2011/"), 22 | dirlistonly = TRUE, 23 | .opts = list(followlocation = TRUE)) 24 | fileNames2011 <- getHTMLLinks(fileURLs2011) 25 | 26 | fileNames <- union(fileNames2001, fileNames2011) 27 | fileNames <- grep("(Species|SpeciesGroups)_.*\\.tif$", fileNames, value = TRUE) 28 | 29 | allSpp <- fileNames |> 30 | sub("_v1\\.tif", "", x = _) |> 31 | sub(".*(Species|SpeciesGroups)_", "", x = _) 32 | allSpp <- unique(allSpp) 33 | 34 | ## remove species that have no layers 35 | sppEquivalencies_CA[!KNN %in% allSpp, KNN := ""] 36 | ## checks 37 | setdiff(sppEquivalencies_CA$KNN, allSpp) 38 | setdiff(allSpp, sppEquivalencies_CA$KNN) 39 | ## Ceres: not sure what these are: "Genc_Spp", "Genh_Spp" 40 | } 41 | 42 | usethis::use_data(sppEquivalencies_CA, overwrite = TRUE) 43 | -------------------------------------------------------------------------------- /data/sppEquivalencies_CA.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PredictiveEcology/LandR/d6dd8512c584840faeac49d1faf7eb620c2c1fcb/data/sppEquivalencies_CA.rda -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | 15x 2 | 1s 3 | 2b 4 | 50M 5 | 5x 6 | 8M 7 | ANPP 8 | Abies 9 | BIOMOD 10 | BSW 11 | Betula 12 | BioSIM 13 | Boreal 14 | Boulanger 15 | Bugfixes 16 | CASFRI 17 | CIMP6 18 | CanESM5 19 | Codecov 20 | Cyr 21 | Ecoprovinces 22 | Ecoregion 23 | FAO 24 | Fekedulegn 25 | KNN 26 | LANDIS 27 | LCC 28 | LCCs 29 | LQ 30 | LandWeb 31 | Larix 32 | MPB 33 | MaxAgeVeg 34 | MinAgeVeg 35 | Mladenoff 36 | Modeling 37 | Montane 38 | MortalityCurve 39 | NFI 40 | NRCAN 41 | NRCan 42 | NTEMS 43 | ORCID 44 | PSP 45 | Peatland 46 | Picea 47 | Pinus 48 | Populus 49 | PredictiveEcology 50 | Pseudotsuga 51 | RCP 52 | Rasterize 53 | Rasters 54 | Rescale 55 | Régnière 56 | SSP 57 | Safranyik 58 | Scheller 59 | Serotiny 60 | Shinneman 61 | SpaDES 62 | Sturtevant 63 | Thuja 64 | Tsuga 65 | Yan 66 | aboveground 67 | additively 68 | al 69 | arcmin 70 | asymptote 71 | balsamea 72 | balsamifera 73 | banksiana 74 | biogeoclimatic 75 | biomasses 76 | boreal 77 | bugfixes 78 | colors 79 | contorta 80 | ecodistricts 81 | ecolocation 82 | ecoregion 83 | ecoregions 84 | ecozones 85 | engelmannii 86 | et 87 | fireSense 88 | glauca 89 | heterophylla 90 | ianmseddy 91 | inflationFactor 92 | iteratively 93 | kNN 94 | laricina 95 | lasiocarpa 96 | lastFireYear 97 | lcc 98 | mariana 99 | menziesii 100 | mertensiana 101 | misalignments 102 | mortalityshape 103 | occidentalis 104 | papyrifera 105 | parallellisation 106 | peatland 107 | percentual 108 | plicata 109 | pre 110 | rasterize 111 | rasters 112 | repo 113 | reproject 114 | reprouter 115 | reprouters 116 | reprouting 117 | repsrout 118 | rescaled 119 | resinosa 120 | resporuting 121 | resprout 122 | resprouter 123 | resprouting 124 | serotinous 125 | serotiny 126 | spp 127 | strobus 128 | subsampled 129 | thermokarst 130 | tremuloides 131 | unburnt 132 | unlink 133 | v0 134 | v1 135 | v3 136 | v4 137 | vectorized 138 | weren 139 | -------------------------------------------------------------------------------- /man-roxygen/FireDisturbance.R: -------------------------------------------------------------------------------- 1 | # these should be in sim$ 2 | #' - `cohortData` 3 | #' - `inactivePixelIndex` 4 | #' - `pixelGroupMap` 5 | #' - `postFireRegenSummary` 6 | #' - `treedFirePixelTableSinceLastDisp` 7 | #' - `rasterToMatch` 8 | #' - `rstCurrentBurn` 9 | #' - `species` 10 | #' - `speciesEcoregion` 11 | #' - `sufficientLight` 12 | -------------------------------------------------------------------------------- /man-roxygen/Nreps.R: -------------------------------------------------------------------------------- 1 | #' @param Nreps the number of simulation replicates/run used to produce summary figures. 2 | #' NOTE: `mclapply` is used internally, so you should set `options(mc.cores = nReps)` 3 | #' to take advantage of parallel processing. 4 | -------------------------------------------------------------------------------- /man-roxygen/burnedPixelCohortData.R: -------------------------------------------------------------------------------- 1 | #' @param burnedPixelCohortData An expanded `cohortData` `data.table` with pixel-level 2 | #' cohort information on burnt pixels and the following (optional) columns: 3 | #' `severity` - fire severity in that pixel calculated based on fire behaviour properties; 4 | #' `firetolerance` - species-level fire tolerance; 5 | #' `severityToleranceDif` - the difference between `severity` and `firetolerance`. 6 | -------------------------------------------------------------------------------- /man-roxygen/cacheTags.R: -------------------------------------------------------------------------------- 1 | #' @param cacheTags a character vector of strings to pass to `Cache(userTags)` 2 | -------------------------------------------------------------------------------- /man-roxygen/calibrate.R: -------------------------------------------------------------------------------- 1 | #' @param calibrate logical. Determines whether to output `postFirePixelCohortData`. 2 | #' Defaults to FALSE 3 | -------------------------------------------------------------------------------- /man-roxygen/cohortData.R: -------------------------------------------------------------------------------- 1 | #' @param cohortData A `data.table` with columns: `pixelGroup`, `ecoregionGroup`, 2 | #' `speciesCode`, and optionally `age`, `B`, `mortality`, `aNPPAct`, and `sumB`. 3 | -------------------------------------------------------------------------------- /man-roxygen/cohortDefinitionCols.R: -------------------------------------------------------------------------------- 1 | #' @param cohortDefinitionCols the columns in `cohortData` that define unique cohorts 2 | #' 3 | -------------------------------------------------------------------------------- /man-roxygen/colsForPixelGroups.R: -------------------------------------------------------------------------------- 1 | #' @param colsForPixelGroups character. `cohortData` columns used to find identical pixels in terms of 2 | #' cohort composition, and group them into `pixelGroups`. 3 | -------------------------------------------------------------------------------- /man-roxygen/currentTime.R: -------------------------------------------------------------------------------- 1 | #' @param currentTime The current simulation time e.g., `time(sim)`. 2 | -------------------------------------------------------------------------------- /man-roxygen/destinationPath.R: -------------------------------------------------------------------------------- 1 | #' @param destinationPath path to data directory where objects will be downloaded or saved to 2 | -------------------------------------------------------------------------------- /man-roxygen/doAssertion.R: -------------------------------------------------------------------------------- 1 | #' @param doAssertion A logical indicating whether some internal tests should be run to 2 | #' ensure the function is running correctly. 3 | #' Default: `getOption("LandR.assertions", TRUE)`. 4 | -------------------------------------------------------------------------------- /man-roxygen/ecoregionMap.R: -------------------------------------------------------------------------------- 1 | #' @param ecoregionMap The `ecoregionMap`, a raster of all the unique ecoregion groupings, 2 | #' which group together pixels of similar biophysical characteristics. 3 | -------------------------------------------------------------------------------- /man-roxygen/initialB.R: -------------------------------------------------------------------------------- 1 | #' @param initialB the initial biomass of new cohorts. Defaults to 10. 2 | #' If `NULL` or `NA`, initial cohort biomass is calculated as in LANDIS-II Biomass Succession 3 | #' Extension v3.2.1 (Scheller & Miranda, 2015): 4 | #' 5 | #' ```r 6 | #' initialB = asInteger(pmin(maxANPP, asInteger(pmax(1, maxANPP \* exp(-1.6 \* sumB / maxB_eco))))) 7 | #' ``` 8 | #' 9 | #' where `maxANPP` and `maxB_eco` are the maximum ANPP and B parameters of the species 10 | #' in question within the pixel's `ecolocation`, and `sumB` is the total stand biomass 11 | #' excluding cohorts with ages less than `successionTimestep`. 12 | -------------------------------------------------------------------------------- /man-roxygen/minRelativeB.R: -------------------------------------------------------------------------------- 1 | #' @param minRelativeB a `data.frame` with the cut points to classify stand shadiness. 2 | -------------------------------------------------------------------------------- /man-roxygen/newPixelCohortData.R: -------------------------------------------------------------------------------- 1 | #' @param newPixelCohortData must be a complete `cohortData` object with newly created 2 | #' cohorts. They do not have to have `pixelGroup` values yet; 3 | #' they can be overlapping with `cohortData`, (i.e., they can be regenerated on empty 4 | #' pixels or on already occupied pixels). 5 | #' Must contain the columns: `pixelIndex`, `speciesCode`, `ecoregionGroup`. 6 | #' The remaining 4 (see `cohortData`) will be created with `0`s. 7 | -------------------------------------------------------------------------------- /man-roxygen/pixelCohortData.R: -------------------------------------------------------------------------------- 1 | #' @param pixelCohortData The full `cohortData` `data.table` 2 | -------------------------------------------------------------------------------- /man-roxygen/pixelGroupMap.R: -------------------------------------------------------------------------------- 1 | #' @param pixelGroupMap A `RasterLayer` with pixel values equal to a pixel group 2 | #' number that corresponds exactly to `pixelGroup` column in `cohortData`. 3 | -------------------------------------------------------------------------------- /man-roxygen/postFirePixelCohortData.R: -------------------------------------------------------------------------------- 1 | #' @param postFirePixelCohortData an empty `cohortData`-like table with columns: 2 | #' `age`, `B`, `mortality`, `aNPPAct`, and `sumB` removed; and `pixelIndex` added. 3 | -------------------------------------------------------------------------------- /man-roxygen/postFireRegenSummary.R: -------------------------------------------------------------------------------- 1 | #' @param postFireRegenSummary a data.table summarizing for which species serotiny/resprouting were 2 | #' activated and in how many pixels, for each year. Only necessary if `calibrate = TRUE`. 3 | -------------------------------------------------------------------------------- /man-roxygen/rasterToMatch.R: -------------------------------------------------------------------------------- 1 | #' @param rasterToMatch A `RasterLayer` objects to use as the template for all subsequent 2 | #' raster operations (i.e., the one used throughout the simulation). 3 | -------------------------------------------------------------------------------- /man-roxygen/rasterToMatchLarge.R: -------------------------------------------------------------------------------- 1 | #' @param rasterToMatchLarge the `rasterToMatchLarge` object from `sim` 2 | -------------------------------------------------------------------------------- /man-roxygen/rstLCC.R: -------------------------------------------------------------------------------- 1 | #' @param rstLCC raster of land-cover class, e.g., LCC2005 2 | -------------------------------------------------------------------------------- /man-roxygen/species.R: -------------------------------------------------------------------------------- 1 | #' @param species a `data.table` with species traits such as longevity, shade tolerance, etc. 2 | #' Must have column `speciesCode`, with species names/IDs. The following is a 3 | #' list of default trait columns: 4 | #' - "species" same as "speciesCode" -- species ID name 5 | #' - "speciesCode" 6 | #' - "Area" -- inherited from LANDIS-II default table, the Canadian ecoregion 7 | #' from which traits where derived. Not used during the simulation 8 | #' - "firetolerance" -- module*relative* (to other species) fire tolerance 9 | #' - "growthcurve" and "mortalityshape" -- growth curve shape parameters. 10 | #' - "longevity" -- maximum species age 11 | #' - "postfireregen" -- post-fire regeneration strategy ("serotiny", "resprout" or "none") 12 | #' - "resproutprob" -- probability of resprouting 13 | #' - "resproutage_min" -- minimum age at which species is capable of resprouting 14 | #' - "resproutage_max" -- maximum age at which species is capable of resprouting 15 | #' - "seeddistance_eff" -- effective dispersal distance 16 | #' - "seeddistance_max" -- maximum dispersal distance 17 | #' - "shadetolerance" -- *relative* (to other species) shade tolerance 18 | #' - "sexualmature" -- age at sexual maturity 19 | #' Known optional parameters added/needed by some modules (the user may add others for their own modules): 20 | #' - "inflationFactor" -- `Biomass_speciesParameters` module: inflation factor for `maxB` 21 | #' - "growthCurveSource" -- `Biomass_speciesParameters` module: how "growthcurve" was estimated 22 | #' - "mANPPproportion" -- `Biomass_speciesParameters` module: multiplication factor to calculate `maxANPP` from `maxB` 23 | #' - "thermokarsttol" -- `Biomass_disturbances` module: proportion of biomass surviving after thermokarst (i.e. permafrost thaw). Applied equally across cohorts. 24 | #' Parameters inherited from LANDIS-II default table, but not used in LandR at the moment: 25 | #' - "leaflongevity" 26 | #' - "wooddecayrate" 27 | #' - "leafLignin" 28 | #' - "hardsoft" 29 | #' Please see the LANDIS-II Biomass Succession Extension v3.2.1 manual (Scheller and Miranda 2015) 30 | #' for further detail. 31 | -------------------------------------------------------------------------------- /man-roxygen/speciesEcoregion.R: -------------------------------------------------------------------------------- 1 | #' @param speciesEcoregion A `data.table` with `species`-`ecoregion`-specific species trait values. 2 | #' Ecoregion refers to "ecolocation", a categorical variable grouping sites with similar biophysical 3 | #' characteristics. The table should have at least the following columns: `speciesCode` and 4 | #' `ecoregionGroup`, character representation of species and ecoregion groups respectively, 5 | #' `maxB` the maximum biomass for the species in a given 'ecoregion', `maxANPP` the maximum 6 | #' aboveground net primary productivity and `SEP` the species establishment probability. 7 | #' May contain columns `inflationFactor` (used to adjust `maxB`) and `mANPPproportion` 8 | #' (used to calculate `maxANPP`). 9 | -------------------------------------------------------------------------------- /man-roxygen/speciesLayers.R: -------------------------------------------------------------------------------- 1 | #' @param speciesLayers A `RasterStack` or `RasterLayer` that 2 | #' should contain species cover data in the study area 3 | -------------------------------------------------------------------------------- /man-roxygen/speciesTable.R: -------------------------------------------------------------------------------- 1 | #' @param speciesTable A species traits table, with **at least** the following columns: 2 | #' - `speciesCode` an character representation of species; 3 | #' - `Area` a character of geographical area within a species range for which trait values are relevant; 4 | #' - `longevity` species longevity in years, `sexualmature` age in years at sexual maturity; 5 | #' - `shadetolerance` numeric value between 1-5 of relative shade tolerance (with respect to other species); 6 | #' - `seeddistance_eff` the "effective" seed dispersal distance; 7 | #' - `seeddistance_max` a numeric with the maximum seed dispersal distance; 8 | #' - `mortalityshape` and `growthcurve`: growth curve shape parameters. 9 | #' Other columns (e.g. fire-related traits) can also be included depending on LandR modules in use. 10 | #' Please see the LANDIS-II Biomass Succession Extension v3.2.1 manual (Scheller and Miranda 2015) 11 | #' for further detail. 12 | -------------------------------------------------------------------------------- /man-roxygen/sppColorVect.R: -------------------------------------------------------------------------------- 1 | #' @param sppColorVect A named vector of colours to use for plotting. 2 | #' The names must conform with species name convention used 3 | #' (see [sppEquivalencies_CA] for possible naming 4 | #' conventions) and should also contain a colour for 'Mixed', 5 | #' when a mixed forest type is supported (see `vegLeadingProportion` 6 | #' parameter in [vegTypeGenerator()] for details on mixed 7 | #' forest types). 8 | -------------------------------------------------------------------------------- /man-roxygen/sppEquiv.R: -------------------------------------------------------------------------------- 1 | #' @param sppEquiv table with species name equivalencies between the kNN and final naming formats. 2 | #' See `data("sppEquivalencies_CA", "LandR")`. 3 | #' For functions that have `mixedType`, this only necessary if `mixedType == 2`. 4 | #' If not provided and `mixedType == 2`, will attempt to use `data("sppEquivalencies_CA", "LandR")`. 5 | -------------------------------------------------------------------------------- /man-roxygen/sppEquivCol.R: -------------------------------------------------------------------------------- 1 | #' @param sppEquivCol the column name to use from `sppEquiv`. 2 | #' For functions that have `mixedType`, only necessary if `mixedType == 2`. 3 | #' If not provided and `mixedType == 2`, will attempt to use "Boreal". 4 | -------------------------------------------------------------------------------- /man-roxygen/sppNameVector.R: -------------------------------------------------------------------------------- 1 | #' @param sppNameVector A character vector of species to use. These species must all 2 | #' be from one naming convention, i.e., from one column in the `sppEquiv`. 3 | -------------------------------------------------------------------------------- /man-roxygen/standAgeMap.R: -------------------------------------------------------------------------------- 1 | #' @param standAgeMap A `rasterLayer` of stand ages with attribute `"imputedPixID"` 2 | -------------------------------------------------------------------------------- /man-roxygen/startTime.R: -------------------------------------------------------------------------------- 1 | #' @param startTime date of the last fire year to be considered (e.g., start of fire 2 | #' period counting backwards). If missing, last fire year available will be used. 3 | -------------------------------------------------------------------------------- /man-roxygen/studyArea.R: -------------------------------------------------------------------------------- 1 | #' @param studyArea A `SpatialPolygons*` object used as the principle study region, 2 | #' passed to [reproducible::prepInputs()]. 3 | -------------------------------------------------------------------------------- /man-roxygen/studyAreaName.R: -------------------------------------------------------------------------------- 1 | #' @param studyAreaName character string giving the study area name. 2 | -------------------------------------------------------------------------------- /man-roxygen/successionTimestep.R: -------------------------------------------------------------------------------- 1 | #' @param successionTimestep The time between successive seed dispersal events. 2 | #' In LANDIS-II, this is called "Succession Timestep". 3 | -------------------------------------------------------------------------------- /man-roxygen/sufficientLight.R: -------------------------------------------------------------------------------- 1 | #' @param sufficientLight a `data.frame` (not `data.table`!) containing probability 2 | #' of establishment, given a site's light conditions (`X0`-`X5`) for each level 3 | #' of a species shade tolerance (`1`-`5`). 4 | -------------------------------------------------------------------------------- /man-roxygen/summary_plots.R: -------------------------------------------------------------------------------- 1 | #' @param studyAreaName character string giving the study area name 2 | #' 3 | #' @param climateScenario character string specifying the name of a CIMP6 climate scenario, 4 | #' including SSP, formatted as in `ClimateNA`, using underscores as separator 5 | #' (e.g., 'CanESM5_SSP370'). 6 | #' 7 | #' @param outputDir Path specifying the directory to which outputs figures/objects should be saved. 8 | #' 9 | #' @return list of file names corresponding to the figures and/or objects written to disk 10 | #' 11 | -------------------------------------------------------------------------------- /man-roxygen/treedFirePixelTableSinceLastDisp.R: -------------------------------------------------------------------------------- 1 | #' @param treedFirePixelTableSinceLastDisp data.table with 3 columns: `pixelIndex`, 2 | #' `pixelGroup`, and `burnTime`. Each row represents a forested pixel that was 3 | #' burned up to and including this year, since last dispersal event, with its 4 | #' corresponding `pixelGroup` and time it occurred Pixel group IDs correspond to 5 | #' the last year's `pixelGroupMap` and not necessarily the pixelGroupMap of 6 | #' the `burnTime` year. 7 | -------------------------------------------------------------------------------- /man-roxygen/vegLeadingProportion.R: -------------------------------------------------------------------------------- 1 | #' @param vegLeadingProportion Numeric between 0-1, determining the relative biomass 2 | #' threshold a species needs to pass to be considered "leading". 3 | -------------------------------------------------------------------------------- /man-roxygen/verbose.R: -------------------------------------------------------------------------------- 1 | #' @param verbose Controls message output. Defaults to `getOption("LandR.verbose")` 2 | -------------------------------------------------------------------------------- /man/BioSIM_extractPoints.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biosim.R 3 | \name{BioSIM_extractPoints} 4 | \alias{BioSIM_extractPoints} 5 | \title{Extract point locations from DEM raster to pass to \code{BioSIM} functions} 6 | \usage{ 7 | BioSIM_extractPoints(x) 8 | } 9 | \arguments{ 10 | \item{x}{A digital elevation model (DEM) \code{RasterLayer}.} 11 | } 12 | \value{ 13 | \code{data.table} with columns \code{Name}, \code{Long}, \code{Lat}, \code{Elev}. 14 | } 15 | \description{ 16 | Extract point locations from DEM raster to pass to \code{BioSIM} functions 17 | } 18 | \seealso{ 19 | \code{\link[=prepInputsCanDEM]{prepInputsCanDEM()}} 20 | } 21 | -------------------------------------------------------------------------------- /man/BioSIM_getMPBSLR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biosim.R 3 | \name{BioSIM_getMPBSLR} 4 | \alias{BioSIM_getMPBSLR} 5 | \title{Get annual historic and projected MPB climate suitability maps from \code{BioSIM}} 6 | \usage{ 7 | BioSIM_getMPBSLR(dem, years, SLR = "R", climModel = "GCM4", rcp = "RCP45") 8 | } 9 | \arguments{ 10 | \item{dem}{\code{RasterLayer} of elevation data (m).} 11 | 12 | \item{years}{numeric vector corresponding to the years to retrieve.} 13 | 14 | \item{SLR}{character. Specifies which climate suitability index to extract. 15 | Currently, one of \code{"S"}, \code{"L"}, \code{"R"}, or \code{"G"}, 16 | corresponding to Safranyik-P3P4, Logan-2b, Régnière Cold Tolerance Survival, or 17 | their Geometric product (S\*L\*R), respectively.} 18 | 19 | \item{climModel}{climate model to use. one of \code{"GCM4"} or \code{"RCM4"}.} 20 | 21 | \item{rcp}{RCP scenario to use. one of \code{"RCP45"} or \code{"RCP85"}.} 22 | } 23 | \value{ 24 | \code{RasterStack} 25 | } 26 | \description{ 27 | Raster stacks for all 9 MPB climate indices. See \code{BioSIM::getModelHelp("MPB_SLR")}. 28 | } 29 | \note{ 30 | Although the BioSIM MPB_SLR model provides several other indices 31 | (see \code{BioSIM::getModelHelp("MPB_SLR")}), only 4 are currently used here. 32 | } 33 | -------------------------------------------------------------------------------- /man/BioSIM_getWindAnnual.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biosim.R 3 | \name{BioSIM_getWindAnnual} 4 | \alias{BioSIM_getWindAnnual} 5 | \title{Get annual historic and projected wind maps from \code{BioSIM}} 6 | \usage{ 7 | BioSIM_getWindAnnual(dem, years, climModel = "GCM4", rcp = "RCP45") 8 | } 9 | \arguments{ 10 | \item{dem}{\code{RasterLayer} of elevation data (m).} 11 | 12 | \item{years}{numeric vector corresponding to the years to retrieve.} 13 | 14 | \item{climModel}{climate model to use. one of \code{"GCM4"} or \code{"RCM4"}.} 15 | 16 | \item{rcp}{RCP scenario to use. one of \code{"RCP45"} or \code{"RCP85"}.} 17 | } 18 | \value{ 19 | \code{RasterStack} 20 | } 21 | \description{ 22 | Get annual historic and projected wind maps from \code{BioSIM} 23 | } 24 | -------------------------------------------------------------------------------- /man/BioSIM_getWindMonthly.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biosim.R 3 | \name{BioSIM_getWindMonthly} 4 | \alias{BioSIM_getWindMonthly} 5 | \title{Get monthly historic and projected wind maps from \code{BioSIM}} 6 | \usage{ 7 | BioSIM_getWindMonthly(dem, years, months, climModel = "GCM4", rcp = "RCP45") 8 | } 9 | \arguments{ 10 | \item{dem}{\code{RasterLayer} of elevation data (m).} 11 | 12 | \item{years}{numeric vector corresponding to the years to retrieve.} 13 | 14 | \item{months}{numeric vector corresponding to the months to retrieve 15 | (e.g., \code{6:8} for June through August).} 16 | 17 | \item{climModel}{climate model to use. one of \code{"GCM4"} or \code{"RCM4"}.} 18 | 19 | \item{rcp}{RCP scenario to use. one of \code{"RCP45"} or \code{"RCP85"}.} 20 | } 21 | \value{ 22 | \code{RasterStack} 23 | } 24 | \description{ 25 | Get monthly historic and projected wind maps from \code{BioSIM} 26 | } 27 | -------------------------------------------------------------------------------- /man/CASFRItoSpRasts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepSpeciesLayers.R 3 | \name{CASFRItoSpRasts} 4 | \alias{CASFRItoSpRasts} 5 | \title{\code{CASFRItoSpRasts}} 6 | \usage{ 7 | CASFRItoSpRasts( 8 | CASFRIRas, 9 | CASFRIattrLong, 10 | CASFRIdt, 11 | sppEquiv, 12 | sppEquivCol, 13 | destinationPath 14 | ) 15 | } 16 | \arguments{ 17 | \item{CASFRIRas}{TODO: description needed} 18 | 19 | \item{CASFRIattrLong}{TODO: description needed} 20 | 21 | \item{CASFRIdt}{TODO: description needed} 22 | 23 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 24 | See \code{data("sppEquivalencies_CA", "LandR")}. 25 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 26 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 27 | 28 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 29 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 30 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 31 | 32 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 33 | } 34 | \value{ 35 | TODO: description needed 36 | } 37 | \description{ 38 | TODO: description and title needed 39 | } 40 | -------------------------------------------------------------------------------- /man/Colors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{Colors} 4 | \alias{Colors} 5 | \title{Helper for setting Raster or \code{SpatRaster} colors} 6 | \usage{ 7 | Colors(ras, cols, n = NULL) 8 | } 9 | \arguments{ 10 | \item{ras}{A \verb{Raster*} or \code{SpatRaster} class object.} 11 | 12 | \item{cols}{a character vector of colours. See examples. Can also be a \code{data.frame}, 13 | see \code{terra::coltab}} 14 | 15 | \item{n}{A numeric scalar giving the number of colours to create. Passed to 16 | \verb{quickPlot::setColors(ras, n = n) <- }. If missing, then \code{n} will be \code{length(cols)}} 17 | } 18 | \description{ 19 | This is a wrapper to help with migration to \pkg{terra}. 20 | Currently can only be used for a single layer \code{SpatRaster} or a \code{RasterLayer}. 21 | } 22 | \examples{ 23 | \donttest{ 24 | cols <- colorRampPalette(c("blue", "red"))(12) 25 | ras <- terra::rast(matrix(1:100, 10, 10)) 26 | ras <- Colors(ras, cols) 27 | terra::plot(ras) 28 | 29 | ras <- raster::raster(matrix(1:100, 10, 10)) 30 | ras <- Colors(ras, cols) 31 | raster::plot(ras) 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /man/LandR-deprecated.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R, R/prepSpeciesLayers.R 3 | \name{makeVegTypeMap} 4 | \alias{makeVegTypeMap} 5 | \alias{loadkNNSpeciesLayersValidation} 6 | \alias{prepSpeciesLayers_KNN2011} 7 | \title{Make a vegetation type map from a stack of species abundances} 8 | \usage{ 9 | makeVegTypeMap(speciesStack, vegLeadingProportion, mixed, ...) 10 | 11 | loadkNNSpeciesLayersValidation( 12 | dPath, 13 | rasterToMatch, 14 | studyArea, 15 | sppEquiv, 16 | knnNamesCol = "KNN", 17 | sppEquivCol, 18 | thresh = 1, 19 | url, 20 | ... 21 | ) 22 | 23 | prepSpeciesLayers_KNN2011( 24 | destinationPath, 25 | outputPath, 26 | url = NULL, 27 | studyArea, 28 | rasterToMatch, 29 | sppEquiv, 30 | sppEquivCol, 31 | thresh = 10, 32 | ... 33 | ) 34 | } 35 | \arguments{ 36 | \item{speciesStack}{A \code{RasterStack} of species abundances. 37 | This must be one \code{RasterLayer} per species.} 38 | 39 | \item{vegLeadingProportion}{Numeric between 0-1, determining the relative biomass 40 | threshold a species needs to pass to be considered "leading".} 41 | 42 | \item{mixed}{Deprecated. See \code{mixedType} argument to \link{vegTypeMapGenerator}.} 43 | 44 | \item{...}{Additional arguments passed to \code{\link[reproducible:Cache]{reproducible::Cache()}} 45 | and \code{\link[=equivalentName]{equivalentName()}}.} 46 | 47 | \item{dPath}{path to the data directory} 48 | 49 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 50 | raster operations (i.e., the one used throughout the simulation).} 51 | 52 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 53 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 54 | 55 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 56 | See \code{data("sppEquivalencies_CA", "LandR")}. 57 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 58 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 59 | 60 | \item{knnNamesCol}{character string indicating the column in \code{sppEquiv} 61 | containing kNN species names. 62 | Default \code{"KNN"} for when \code{sppEquivalencies_CA} is used.} 63 | 64 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 65 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 66 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 67 | 68 | \item{thresh}{the minimum number of pixels where the species must have 69 | \code{biomass > 0} to be considered present in the study area. 70 | Defaults to 1.} 71 | 72 | \item{url}{the source url for the data, passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}} 73 | 74 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 75 | 76 | \item{outputPath}{path to output directory} 77 | } 78 | \value{ 79 | A factor raster 80 | 81 | A raster stack of percent cover layers by species. 82 | } 83 | \description{ 84 | \code{makeVegTypeMap} is a wrapper around \code{vegTypeMapGenerator} 85 | that works from a species stack of percent cover. 86 | These do not have to sum to 100\%\% 87 | 88 | Downloads the 2011 kNN species cover layers from the Canadian Forestry Service, 89 | National Inventory System, for validation. 90 | } 91 | -------------------------------------------------------------------------------- /man/LandR-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LandR-package.R 3 | \docType{package} 4 | \name{LandR-package} 5 | \alias{LandR} 6 | \alias{LandR-package} 7 | \title{\code{LandR} package} 8 | \description{ 9 | Utilities for 'LandR' suite of landscape simulation models. 10 | These models simulate forest vegetation dynamics based on LANDIS-II, and 11 | incorporate fire and insect disturbance, as well as other important ecological 12 | processes. Models are implemented as 'SpaDES' modules. 13 | } 14 | \section{Package options}{ 15 | 16 | 17 | \code{LandR} packages use the following \code{\link[=options]{options()}} to configure behaviour: 18 | \itemize{ 19 | \item \code{LandR.assertions}: If \code{TRUE}, additional code checks are run during function calls. 20 | Default \code{FALSE}. 21 | } 22 | } 23 | 24 | \seealso{ 25 | Useful links: 26 | \itemize{ 27 | \item \url{https://landr.predictiveecology.org} 28 | \item \url{https://github.com/PredictiveEcology/LandR} 29 | \item Report bugs at \url{https://github.com/PredictiveEcology/LandR/issues} 30 | } 31 | 32 | } 33 | \author{ 34 | \strong{Maintainer}: Eliot J B McIntire \email{eliot.mcintire@nrcan-rncan.gc.ca} (\href{https://orcid.org/0000-0002-6914-8316}{ORCID}) 35 | 36 | Authors: 37 | \itemize{ 38 | \item Alex M Chubaty \email{achubaty@for-cast.ca} (\href{https://orcid.org/0000-0001-7146-8135}{ORCID}) 39 | \item Ceres Barros \email{ceres.barros@ubc.ca} (\href{https://orcid.org/0000-0003-4036-977X}{ORCID}) 40 | \item Ian M S Eddy \email{ian.eddy@nrcan-rncan.gc.ca} (\href{https://orcid.org/0000-0001-7397-2116}{ORCID}) 41 | } 42 | 43 | Other contributors: 44 | \itemize{ 45 | \item His Majesty the King in Right of Canada, as represented by the Minister of Natural Resources Canada [copyright holder] 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /man/NAcover2zero.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepSpeciesLayers.R 3 | \name{NAcover2zero} 4 | \alias{NAcover2zero} 5 | \title{Convert \code{NA} values in \code{speciesLayers} to zeros} 6 | \usage{ 7 | NAcover2zero(speciesLayers, rasterToMatch) 8 | } 9 | \arguments{ 10 | \item{speciesLayers}{A \code{RasterStack} or \code{RasterLayer} that 11 | should contain species cover data in the study area} 12 | 13 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 14 | raster operations (i.e., the one used throughout the simulation).} 15 | } 16 | \value{ 17 | the \code{speciesLayers} with \code{0} in pixels that had \code{NA} 18 | } 19 | \description{ 20 | Pixels that are \code{NA} but are inside \code{rasterToMatch} may need to be converted to \code{0}, 21 | as they can could still potentially be forested 22 | } 23 | -------------------------------------------------------------------------------- /man/WardKernel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/seedDispersalLANDIS.R 3 | \docType{methods} 4 | \name{WardKernel} 5 | \alias{WardKernel} 6 | \alias{Ward} 7 | \title{Ward Dispersal Kernel -- vectorized, optimized for speed} 8 | \usage{ 9 | Ward(dist, cellSize, effDist, maxDist, k, b, algo = 2) 10 | } 11 | \arguments{ 12 | \item{dist}{A vector of distances to evaluate kernel against} 13 | 14 | \item{cellSize}{A numeric, length 1, of the cell resolution (e.g., res(raster))} 15 | 16 | \item{effDist}{A vector of effective distance (parameter in kernel), 17 | with same length as \code{dist}} 18 | 19 | \item{maxDist}{A vector of maximum distance (parameter in kernel), 20 | with same length as \code{dist}} 21 | 22 | \item{k}{A parameter in the kernel} 23 | 24 | \item{b}{A parameter in the kernel} 25 | 26 | \item{algo}{Either 1 or 2. 2 is faster and is default. 1 is "simpler code" as it 27 | uses \code{ifelse}} 28 | } 29 | \description{ 30 | A probability distribution used in LANDIS-II. 31 | } 32 | \author{ 33 | Eliot McIntire 34 | } 35 | -------------------------------------------------------------------------------- /man/addNoPixel2CohortData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{addNoPixel2CohortData} 4 | \alias{addNoPixel2CohortData} 5 | \title{Add number of pixels per \code{pixelGroup} and add it has a new column to \code{cohortData}} 6 | \usage{ 7 | addNoPixel2CohortData( 8 | cohortData, 9 | pixelGroupMap, 10 | cohortDefinitionCols = c("pixelGroup", "age", "speciesCode"), 11 | doAssertion = getOption("LandR.assertions", TRUE) 12 | ) 13 | } 14 | \arguments{ 15 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 16 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 17 | 18 | \item{pixelGroupMap}{A \code{RasterLayer} with pixel values equal to a pixel group 19 | number that corresponds exactly to \code{pixelGroup} column in \code{cohortData}.} 20 | 21 | \item{cohortDefinitionCols}{the columns in \code{cohortData} that define unique cohorts} 22 | 23 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 24 | ensure the function is running correctly. 25 | Default: \code{getOption("LandR.assertions", TRUE)}.} 26 | } 27 | \value{ 28 | An \code{cohortData} \code{dat.table} with a new \code{noPixels} 29 | column 30 | } 31 | \description{ 32 | Add number of pixels per \code{pixelGroup} and add it has a new column to \code{cohortData} 33 | } 34 | -------------------------------------------------------------------------------- /man/addPixels2CohortData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{addPixels2CohortData} 4 | \alias{addPixels2CohortData} 5 | \title{Generate \code{cohortData} table per pixel:} 6 | \usage{ 7 | addPixels2CohortData( 8 | cohortData, 9 | pixelGroupMap, 10 | cohortDefinitionCols = c("pixelGroup", "age", "speciesCode"), 11 | doAssertion = getOption("LandR.assertions", TRUE) 12 | ) 13 | } 14 | \arguments{ 15 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 16 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 17 | 18 | \item{pixelGroupMap}{A \code{RasterLayer} with pixel values equal to a pixel group 19 | number that corresponds exactly to \code{pixelGroup} column in \code{cohortData}.} 20 | 21 | \item{cohortDefinitionCols}{the columns in \code{cohortData} that define unique cohorts} 22 | 23 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 24 | ensure the function is running correctly. 25 | Default: \code{getOption("LandR.assertions", TRUE)}.} 26 | } 27 | \value{ 28 | An expanded \code{cohortData} \code{data.table} with a new \code{pixelIndex} column. 29 | } 30 | \description{ 31 | Generate \code{cohortData} table per pixel: 32 | } 33 | -------------------------------------------------------------------------------- /man/aggregateRasByDT.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{aggregateRasByDT} 4 | \alias{aggregateRasByDT} 5 | \title{Aggregate a raster} 6 | \usage{ 7 | aggregateRasByDT(ras, newRas, fn = sum) 8 | } 9 | \arguments{ 10 | \item{ras}{\code{RasterLayer} to aggregate} 11 | 12 | \item{newRas}{\code{RasterLayer} to match} 13 | 14 | \item{fn}{function to use to aggregate pixel values} 15 | } 16 | \value{ 17 | \code{RasterLayer} 18 | } 19 | \description{ 20 | Uses \pkg{data.table} to perform aggregation calculations, which is faster than 21 | \code{raster::aggregate}. 22 | } 23 | -------------------------------------------------------------------------------- /man/asInteger.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{asInteger} 4 | \alias{asInteger} 5 | \title{Convert numeric values to rounded integers} 6 | \usage{ 7 | asInteger(x) 8 | } 9 | \arguments{ 10 | \item{x}{A numeric vector} 11 | } 12 | \value{ 13 | An integer vector of length \code{x}, rounded to zero decimal places 14 | prior to \code{as.integer} 15 | } 16 | \description{ 17 | Essentially a wrapper around \code{round}, rather than \code{truncate}, which is what \code{as.integer} 18 | does. Internally, this is simply \code{as.integer(floor(x + 0.5))}. 19 | } 20 | \note{ 21 | Values ending in \code{.5} will be rounded up, whether positive or negative. 22 | This is different than \code{round}. 23 | } 24 | \examples{ 25 | x <- seq(-2, 2, 0.25) 26 | data.frame(dbl = x, int = asInteger(x)) 27 | } 28 | -------------------------------------------------------------------------------- /man/assertPostPartialDist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/assertions.R 3 | \name{assertPostPartialDist} 4 | \alias{assertPostPartialDist} 5 | \title{Assert post-fire disturbance mortality and regeneration} 6 | \usage{ 7 | assertPostPartialDist( 8 | cohortDataOrig, 9 | pixelGroupMapOrig, 10 | cohortDataNew, 11 | pixelGroupMapNew, 12 | postDistPixelCohortData, 13 | distrbdPixelCohortData, 14 | doAssertion = getOption("LandR.assertions", TRUE) 15 | ) 16 | } 17 | \arguments{ 18 | \item{cohortDataOrig}{original \code{cohortData} (prior to any modification)} 19 | 20 | \item{pixelGroupMapOrig}{original \code{pixelGroupMap} (prior to any modification)} 21 | 22 | \item{cohortDataNew}{modified \code{cohortData} output from \code{updateCohortData()}} 23 | 24 | \item{pixelGroupMapNew}{modified \code{pixelGroupMap} output from \code{updateCohortData()}} 25 | 26 | \item{postDistPixelCohortData}{modified \code{cohortData} output from \code{updateCohortData()}} 27 | 28 | \item{distrbdPixelCohortData}{\code{cohortData}-like object containing all dead, surviving and 29 | new cohorts (i.e. activated by serotiny/resprouting)} 30 | 31 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 32 | ensure the function is running correctly. 33 | Default: \code{getOption("LandR.assertions", TRUE)}.} 34 | } 35 | \description{ 36 | Assert post-fire disturbance mortality and regeneration 37 | } 38 | -------------------------------------------------------------------------------- /man/assignLightProb.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{assignLightProb} 4 | \alias{assignLightProb} 5 | \title{Assign light probability} 6 | \usage{ 7 | assignLightProb( 8 | sufficientLight, 9 | newCohortData, 10 | interpolate = TRUE, 11 | doAssertion = getOption("LandR.assertions", TRUE) 12 | ) 13 | } 14 | \arguments{ 15 | \item{sufficientLight}{a \code{data.frame} (not \code{data.table}!) containing probability 16 | of establishment, given a site's light conditions (\code{X0}-\code{X5}) for each level 17 | of a species shade tolerance (\code{1}-\code{5}).} 18 | 19 | \item{newCohortData}{a modified version of \code{cohortData} that contains new cohorts.} 20 | 21 | \item{interpolate}{Logical. Activates interpolation of probabilities of establishment between 22 | any two values of shade tolerance in the sufficient light table, allowing species shade tolerance 23 | trait values to take any decimal value between 1 and 5 (inclusively). If false, species shade tolerances 24 | can only take integer values between 1 and 5 (inclusively).} 25 | 26 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 27 | ensure the function is running correctly. 28 | Default: \code{getOption("LandR.assertions", TRUE)}.} 29 | } 30 | \value{ 31 | \code{newCohortData} with a \code{lightProb} column 32 | } 33 | \description{ 34 | Assign light probability 35 | } 36 | -------------------------------------------------------------------------------- /man/biomodEnsembleFrcstWrapper.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biomodWrappers.R 3 | \name{biomodEnsembleFrcstWrapper} 4 | \alias{biomodEnsembleFrcstWrapper} 5 | \title{Simple wrapper around \code{\link[biomod2:BIOMOD_EnsembleForecasting]{biomod2::BIOMOD_EnsembleForecasting()}}} 6 | \usage{ 7 | biomodEnsembleFrcstWrapper( 8 | bm.em, 9 | bm.proj = NULL, 10 | proj.name = NULL, 11 | new.env = NULL, 12 | new.env.xy = NULL, 13 | keep.in.memory = TRUE, 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{bm.em}{output of \link[biomod2:BIOMOD_EnsembleModeling]{biomod2::BIOMOD_EnsembleModeling}} 19 | 20 | \item{bm.proj}{output of \link[biomod2:BIOMOD_Projection]{biomod2::BIOMOD_Projection}} 21 | 22 | \item{proj.name}{passed to \link[biomod2:BIOMOD_Projection]{biomod2::BIOMOD_Projection}} 23 | 24 | \item{new.env}{passed to \link[biomod2:BIOMOD_EnsembleForecasting]{biomod2::BIOMOD_EnsembleForecasting}} 25 | 26 | \item{new.env.xy}{passed to \link[biomod2:BIOMOD_EnsembleForecasting]{biomod2::BIOMOD_EnsembleForecasting}} 27 | 28 | \item{keep.in.memory}{passed to \link[biomod2:BIOMOD_EnsembleForecasting]{biomod2::BIOMOD_EnsembleForecasting}} 29 | 30 | \item{...}{passed to \link[reproducible:Cache]{reproducible::Cache}} 31 | } 32 | \description{ 33 | Simple wrapper around \code{\link[biomod2:BIOMOD_EnsembleForecasting]{biomod2::BIOMOD_EnsembleForecasting()}} 34 | } 35 | -------------------------------------------------------------------------------- /man/biomodEnsembleProjMaps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biomodWrappers.R 3 | \name{biomodEnsembleProjMaps} 4 | \alias{biomodEnsembleProjMaps} 5 | \title{Make maps from \code{BIOMOD_EnsembleForecasting()} results} 6 | \usage{ 7 | biomodEnsembleProjMaps(bm.em.proj, predModel, rasTemplate, origCRS) 8 | } 9 | \arguments{ 10 | \item{bm.em.proj}{output of \code{biomod2::BIOMOD_EnsembleForecasting()}. 11 | Note that \code{x} and \code{y}coordinates extracted from \code{bm.em.proj@coord} must be in the same 12 | projection as \code{rasTemplate}.} 13 | 14 | \item{predModel}{character. Which model predictions should be used. 15 | Choose one of \code{bm.em.proj@models.projected}.} 16 | 17 | \item{rasTemplate}{a template \code{RasterLayer} or \code{SpatRaster} that can be used to map the projections} 18 | 19 | \item{origCRS}{character. The original CRS projection of \code{bm.em.proj@coord}.} 20 | } 21 | \value{ 22 | a \code{SpatRaster} object 23 | } 24 | \description{ 25 | Make maps from \code{BIOMOD_EnsembleForecasting()} results 26 | } 27 | -------------------------------------------------------------------------------- /man/biomodEnsembleWrapper.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biomodWrappers.R 3 | \name{biomodEnsembleWrapper} 4 | \alias{biomodEnsembleWrapper} 5 | \title{BIOMOD_EnsembleModeling wrapper} 6 | \usage{ 7 | biomodEnsembleWrapper(bm.mod, metric.select.thresh = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{bm.mod}{output of \link[biomod2:BIOMOD_Modeling]{biomod2::BIOMOD_Modeling}} 11 | 12 | \item{metric.select.thresh}{passed \link[biomod2:BIOMOD_EnsembleModeling]{biomod2::BIOMOD_EnsembleModeling}. 13 | By default no thresholding is applied.} 14 | 15 | \item{...}{passed to \link[reproducible:Cache]{reproducible::Cache}} 16 | } 17 | \description{ 18 | BIOMOD_EnsembleModeling wrapper 19 | } 20 | -------------------------------------------------------------------------------- /man/biomodModelingWrapper.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biomodWrappers.R 3 | \name{biomodModelingWrapper} 4 | \alias{biomodModelingWrapper} 5 | \title{BIOMOD_Modeling wrapper} 6 | \usage{ 7 | biomodModelingWrapper( 8 | sp, 9 | responseVar, 10 | responseVarData, 11 | predictorVars, 12 | predictorVarsData, 13 | dir.name, 14 | BIOMOD_ModelingArgs = list(models = c("GLM", "MARS"), bm.options = NULL, CV.k = 5, 15 | CV.perc = 100, metric.eval = c("TSS", "ROC"), modeling.id = "test"), 16 | ... 17 | ) 18 | } 19 | \arguments{ 20 | \item{sp}{character of species name to subset \code{responseVarData} table} 21 | 22 | \item{responseVar}{character vector, or list of character vectors, of response 23 | variable (column) to subset \code{responseVarData} table. If a list, it should 24 | be named according to \code{sp}, for subsetting.} 25 | 26 | \item{responseVarData}{a data.table or list of data.tables with environmental data. 27 | If a list, it should be named according to \code{sp}, for subsetting.#'} 28 | 29 | \item{predictorVars}{character vector, or list of character vectors, of environmental 30 | variables (columns) to subset \code{predictorVarsData} table. If a list, it should 31 | be named according to \code{sp}, for subsetting.} 32 | 33 | \item{predictorVarsData}{environmental data.} 34 | 35 | \item{dir.name}{passed to \link[biomod2:BIOMOD_FormatingData]{biomod2::BIOMOD_FormatingData}} 36 | 37 | \item{BIOMOD_ModelingArgs}{a named list of arguments passed to \link[biomod2:BIOMOD_Modeling]{biomod2::BIOMOD_Modeling}} 38 | 39 | \item{...}{further arguments passed to \link[reproducible:Cache]{reproducible::Cache}} 40 | } 41 | \description{ 42 | BIOMOD_Modeling wrapper 43 | } 44 | -------------------------------------------------------------------------------- /man/biomodProjWrapper.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biomodWrappers.R 3 | \name{biomodProjWrapper} 4 | \alias{biomodProjWrapper} 5 | \title{BIOMOD_Projection wrapper} 6 | \usage{ 7 | biomodProjWrapper( 8 | bm.mod, 9 | proj.name = "testProj", 10 | new.env = NULL, 11 | new.env.xy = NULL, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{bm.mod}{passed to \link[biomod2:BIOMOD_Projection]{biomod2::BIOMOD_Projection}. If not supplied 17 | the data used to fit the model will be used.} 18 | 19 | \item{proj.name}{passed to \link[biomod2:BIOMOD_Projection]{biomod2::BIOMOD_Projection}} 20 | 21 | \item{new.env}{passed to \link[biomod2:BIOMOD_Projection]{biomod2::BIOMOD_Projection}} 22 | 23 | \item{new.env.xy}{passed to \link[biomod2:BIOMOD_Projection]{biomod2::BIOMOD_Projection}} 24 | 25 | \item{...}{passed to \link[reproducible:Cache]{reproducible::Cache}} 26 | } 27 | \description{ 28 | BIOMOD_Projection wrapper 29 | } 30 | -------------------------------------------------------------------------------- /man/calcSeverityB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fireSeverity.R 3 | \name{calcSeverityB} 4 | \alias{calcSeverityB} 5 | \title{Calculate fire severity} 6 | \usage{ 7 | calcSeverityB(cohortData, burnedPixelCohortData) 8 | } 9 | \arguments{ 10 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 11 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 12 | 13 | \item{burnedPixelCohortData}{An expanded \code{cohortData} \code{data.table} with pixel-level 14 | cohort information on burnt pixels and the following (optional) columns: 15 | \code{severity} - fire severity in that pixel calculated based on fire behaviour properties; 16 | \code{firetolerance} - species-level fire tolerance; 17 | \code{severityToleranceDif} - the difference between \code{severity} and \code{firetolerance}.} 18 | } 19 | \value{ 20 | \code{data.table} with columns \code{pixelIndex}, 21 | \code{pixelGroup} and \code{severityB} (absolute biomass lost) 22 | and \code{severityPropB} (proportion of biomass lost) 23 | } 24 | \description{ 25 | Calculates fire severity as the loss of pre-fire to 26 | post-fire biomass (in absolute and percentual terms). 27 | } 28 | \note{ 29 | if \code{burnedPixelCohortData} does not have a \code{B} 30 | column, the fire is assumed to be stand replacing (i.e. 31 | we assume B to be 0 across all pixels/cohorts in 32 | \code{burnedPixelCohortData}) 33 | } 34 | -------------------------------------------------------------------------------- /man/calcSiteShade.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/light-shade.R 3 | \name{calcSiteShade} 4 | \alias{calcSiteShade} 5 | \title{Calculate site shade} 6 | \usage{ 7 | calcSiteShade(currentTime, cohortData, speciesEcoregion, minRelativeB) 8 | } 9 | \arguments{ 10 | \item{currentTime}{The current simulation time e.g., \code{time(sim)}.} 11 | 12 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 13 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 14 | 15 | \item{speciesEcoregion}{A \code{data.table} with \code{species}-\code{ecoregion}-specific species trait values. 16 | Ecoregion refers to "ecolocation", a categorical variable grouping sites with similar biophysical 17 | characteristics. The table should have at least the following columns: \code{speciesCode} and 18 | \code{ecoregionGroup}, character representation of species and ecoregion groups respectively, 19 | \code{maxB} the maximum biomass for the species in a given 'ecoregion', \code{maxANPP} the maximum 20 | aboveground net primary productivity and \code{SEP} the species establishment probability. 21 | May contain columns \code{inflationFactor} (used to adjust \code{maxB}) and \code{mANPPproportion} 22 | (used to calculate \code{maxANPP}).} 23 | 24 | \item{minRelativeB}{a \code{data.frame} with the cut points to classify stand shadiness.} 25 | } 26 | \value{ 27 | \code{cohortData} table with a \code{siteShade} column 28 | } 29 | \description{ 30 | Calculate site shade 31 | } 32 | \seealso{ 33 | \code{\link[=makeMinRelativeB]{makeMinRelativeB()}} 34 | } 35 | -------------------------------------------------------------------------------- /man/calculateClimateEffect.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nullClimate.R 3 | \name{calculateClimateEffect} 4 | \alias{calculateClimateEffect} 5 | \title{Null climate effect} 6 | \usage{ 7 | calculateClimateEffect(cohortData, ...) 8 | } 9 | \arguments{ 10 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 11 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 12 | 13 | \item{...}{additional arguments that are passed to LandR.CS} 14 | } 15 | \value{ 16 | \code{data.table} with \code{pixelGroup}, \code{age} and \code{speciesCode}, as well as 17 | \code{mortPred} and \code{growthPred} columns with \\% reduction/increase of mortality and 18 | growth biomasses resulting from a climate effect. 19 | These percentages are later multiplied by the by baseline biomasses of mortality and growth 20 | (e.g. 0\\% meaning total mortality or growth reduction, and 100\\% meaning no reduction). 21 | This default, no climate effect, function outputs 100\\% for all cohorts for both 22 | \code{mortPred} and \code{growthPred}. 23 | } 24 | \description{ 25 | Default climate effects function in the case where no climate effect is simulated 26 | } 27 | \details{ 28 | the \code{cohortData} object is used to calculate the \\% 29 | reduction/increase of mortality and growth biomasses per cohort. 30 | } 31 | -------------------------------------------------------------------------------- /man/checkSpeciesTraits.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{checkSpeciesTraits} 4 | \alias{checkSpeciesTraits} 5 | \title{Check if all species in have trait values} 6 | \usage{ 7 | checkSpeciesTraits(speciesLayers, species, sppColorVect) 8 | } 9 | \arguments{ 10 | \item{speciesLayers}{A \code{RasterStack} or \code{RasterLayer} that 11 | should contain species cover data in the study area} 12 | 13 | \item{species}{a \code{data.table} with species traits such as longevity, shade tolerance, etc. 14 | Must have column \code{speciesCode}, with species names/IDs. The following is a 15 | list of default trait columns: 16 | \itemize{ 17 | \item "species" same as "speciesCode" -- species ID name 18 | \item "speciesCode" 19 | \item "Area" -- inherited from LANDIS-II default table, the Canadian ecoregion 20 | from which traits where derived. Not used during the simulation 21 | \item "firetolerance" -- module\emph{relative} (to other species) fire tolerance 22 | \item "growthcurve" and "mortalityshape" -- growth curve shape parameters. 23 | \item "longevity" -- maximum species age 24 | \item "postfireregen" -- post-fire regeneration strategy ("serotiny", "resprout" or "none") 25 | \item "resproutprob" -- probability of resprouting 26 | \item "resproutage_min" -- minimum age at which species is capable of resprouting 27 | \item "resproutage_max" -- maximum age at which species is capable of resprouting 28 | \item "seeddistance_eff" -- effective dispersal distance 29 | \item "seeddistance_max" -- maximum dispersal distance 30 | \item "shadetolerance" -- \emph{relative} (to other species) shade tolerance 31 | \item "sexualmature" -- age at sexual maturity 32 | Known optional parameters added/needed by some modules (the user may add others for their own modules): 33 | \item "inflationFactor" -- \code{Biomass_speciesParameters} module: inflation factor for \code{maxB} 34 | \item "growthCurveSource" -- \code{Biomass_speciesParameters} module: how "growthcurve" was estimated 35 | \item "mANPPproportion" -- \code{Biomass_speciesParameters} module: multiplication factor to calculate \code{maxANPP} from \code{maxB} 36 | \item "thermokarsttol" -- \code{Biomass_disturbances} module: proportion of biomass surviving after thermokarst (i.e. permafrost thaw). Applied equally across cohorts. 37 | Parameters inherited from LANDIS-II default table, but not used in LandR at the moment: 38 | \item "leaflongevity" 39 | \item "wooddecayrate" 40 | \item "leafLignin" 41 | \item "hardsoft" 42 | Please see the LANDIS-II Biomass Succession Extension v3.2.1 manual (Scheller and Miranda 2015) 43 | for further detail. 44 | }} 45 | 46 | \item{sppColorVect}{A named vector of colours to use for plotting. 47 | The names must conform with species name convention used 48 | (see \link{sppEquivalencies_CA} for possible naming 49 | conventions) and should also contain a colour for 'Mixed', 50 | when a mixed forest type is supported (see \code{vegLeadingProportion} 51 | parameter in \code{\link[=vegTypeGenerator]{vegTypeGenerator()}} for details on mixed 52 | forest types).} 53 | } 54 | \value{ 55 | A \code{list} with the \code{speciesLayers} and \code{sppColorVect} 56 | containing only the species that have trait values in \code{species} 57 | } 58 | \description{ 59 | Check if all species in have trait values 60 | } 61 | -------------------------------------------------------------------------------- /man/columnsForPixelGroups.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \docType{data} 4 | \name{columnsForPixelGroups} 5 | \alias{columnsForPixelGroups} 6 | \title{Default columns that define pixel groups} 7 | \format{ 8 | An object of class \code{character} of length 4. 9 | } 10 | \usage{ 11 | columnsForPixelGroups 12 | } 13 | \description{ 14 | Default columns that define pixel groups 15 | } 16 | \keyword{datasets} 17 | -------------------------------------------------------------------------------- /man/compare.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/terra-raster-utils.R 3 | \name{.compareRas} 4 | \alias{.compareRas} 5 | \alias{.compareCRS} 6 | \title{Compare raster properties} 7 | \usage{ 8 | .compareRas(x, ...) 9 | 10 | .compareCRS(x, y) 11 | } 12 | \arguments{ 13 | \item{x, y}{a \code{Raster}, \code{SpatRaster}, \code{sf}, \code{SpatVector}, or \code{Spatial} object} 14 | 15 | \item{...}{additional \code{Raster} or \code{SpatRaster} objects, and arguments 16 | passed to \code{\link[terra:compareGeom]{terra::compareGeom()}}.} 17 | } 18 | \value{ 19 | the projected extent 20 | } 21 | \description{ 22 | TODO: Move to \code{reproducible} 23 | 24 | TODO: Move to \code{reproducible} 25 | TODO: expand to multiple objects 26 | } 27 | \note{ 28 | this function internally converts \code{Raster} to \code{SpatRaster} to allow using \code{compareGeom()}, 29 | and benefit from its complexity. 30 | } 31 | -------------------------------------------------------------------------------- /man/convertUnwantedLCC2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/convertUnwantedLCC2.R 3 | \name{convertUnwantedLCC2} 4 | \alias{convertUnwantedLCC2} 5 | \title{Convert Land Cover Classes (LCC) to another value in its neighbourhood} 6 | \usage{ 7 | convertUnwantedLCC2( 8 | classesToReplace = 34:36, 9 | rstLCC, 10 | nIterations = 6, 11 | defaultNewValue = NA, 12 | invalidClasses = NA 13 | ) 14 | } 15 | \arguments{ 16 | \item{classesToReplace}{Integer vector of classes that are are to be replaced, 17 | e.g., 34, 35, 36 on LCC2005, which are burned young, burned 10 year, and cities.} 18 | 19 | \item{rstLCC}{raster of land-cover class, e.g., LCC2005} 20 | 21 | \item{nIterations}{the number of iterations to perform} 22 | 23 | \item{defaultNewValue}{the value to assign a pixel in \code{classesToReplace} if no valid pixel 24 | is closer after \code{nIterations}} 25 | 26 | \item{invalidClasses}{classes that are not valid options} 27 | } 28 | \value{ 29 | A \code{rasterLayer} with values in \code{classesToReplace} converted to adjacent values or NA. 30 | } 31 | \description{ 32 | This will search around the pixels on \code{rstLCC} that have 33 | \code{classesToReplace}, and search in iteratively increasing 34 | radii outwards for other Land Cover Classes than the those indicated in 35 | \code{classesToReplace}. 36 | . 37 | } 38 | \author{ 39 | Eliot McIntire Ian Eddy 40 | } 41 | -------------------------------------------------------------------------------- /man/defineFlammable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{defineFlammable} 4 | \alias{defineFlammable} 5 | \title{Define flammability map} 6 | \usage{ 7 | defineFlammable( 8 | LandCoverClassifiedMap = NULL, 9 | nonFlammClasses = c(0L, 25L, 30L, 33L, 36L, 37L, 38L, 39L), 10 | mask = NULL, 11 | to = NULL, 12 | filename2 = NULL 13 | ) 14 | } 15 | \arguments{ 16 | \item{LandCoverClassifiedMap}{A \code{Raster} that represents land cover 17 | (e.g., Land Cover Classified map from 2005 or 2010 from the Canadian Forest Service).} 18 | 19 | \item{nonFlammClasses}{numeric vector defining which classes in \code{LandCoverClassifiedMap}.} 20 | 21 | \item{mask}{A raster to use as a mask (see \code{\link[raster:mask]{raster::mask()}}).} 22 | 23 | \item{to}{Passed to \code{postProcessTo(..., to = to)} and to the \code{mask} arg here, if 24 | \code{mask} is not supplied.} 25 | 26 | \item{filename2}{See \code{\link[reproducible:postProcess]{reproducible::postProcess()}}. Default \code{NULL}.} 27 | } 28 | \description{ 29 | Define flammability map 30 | } 31 | -------------------------------------------------------------------------------- /man/describeCohortData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{describeCohortData} 4 | \alias{describeCohortData} 5 | \title{Summary for \code{cohortData}} 6 | \usage{ 7 | describeCohortData(cohortData) 8 | } 9 | \arguments{ 10 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 11 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 12 | } 13 | \description{ 14 | Summary for \code{cohortData} 15 | } 16 | -------------------------------------------------------------------------------- /man/dot-MLLMaxBPartialPlotData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{.MLLMaxBPartialPlotData} 4 | \alias{.MLLMaxBPartialPlotData} 5 | \title{Prepare data for model plotting} 6 | \usage{ 7 | .MLLMaxBPartialPlotData( 8 | mll, 9 | nonLinModelQuoted, 10 | linModelQuoted, 11 | targetCovar = "cover", 12 | fixMaxCover = TRUE, 13 | maxCover = 1, 14 | data, 15 | fun = "mean", 16 | plotCIs = TRUE 17 | ) 18 | } 19 | \arguments{ 20 | \item{mll}{outputs of an \code{bbmle::mle2} call (the fitted non-linear model), 21 | from which coefficient values will be extracted.} 22 | 23 | \item{nonLinModelQuoted}{The non-linear equation as a \code{call} 24 | (quoted expression) passed to \code{mle2(minuslog1)}. See \code{?mle}. 25 | Accepts equations with three parameters 'A', 'p' and 'k'.} 26 | 27 | \item{linModelQuoted}{A list of linear equations/modes relating each 28 | parameter ('A', 'p' and 'k') with a set of covariates. A \code{call} 29 | (quoted expression) passed to \code{mle2(..., parameters)}. Note that for the 30 | purpose of tree growth, the linear equation determining 'A' should include a 31 | 'cover' predictor indicating the tree cover or dominance in the stand. Should be 32 | scaled between 0 and \code{maxCover}.} 33 | 34 | \item{targetCovar}{the covariate for which variation in maxB values will be shown. 35 | Defaults to showing how maxB values change with "cover". All other covariates except 36 | "age" are averaged. Age values are generated as \code{round(seq(min(age), max(age)*1.5, length.out = 100), 0)}. 37 | When \code{targetCovar != "cover"}, "cover" will be fixed at \code{maxCover}. See \code{fixMaxCover}.} 38 | 39 | \item{fixMaxCover}{logical. If \code{TRUE} and \code{targetCovar != "cover"}, cover is 40 | not averaged and is fixed to \code{maxCover}.} 41 | 42 | \item{maxCover}{numeric. Value indicating maximum cover/dominance.} 43 | 44 | \item{data}{data for estimation of maximum biomass. Should contain at least 45 | an 'age' column. Note that other covariates will be averaged and 'cover' values 46 | will be replaced with the maximum cover value (\code{maxCover}).} 47 | 48 | \item{fun}{The function to apply when summarizing other variables. By default, 49 | the all other variables except age are averaged (\code{"mean"}). Other options are: 50 | \code{"median"}, \code{"min"}, \code{"max"}.} 51 | 52 | \item{plotCIs}{should confidence intervals be calculated and plotted?} 53 | } 54 | \description{ 55 | Prepare data for model plotting 56 | } 57 | \seealso{ 58 | \code{\link[bbmle:mle2]{bbmle::mle2()}} 59 | } 60 | -------------------------------------------------------------------------------- /man/dot-MLLMaxBplotData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{.MLLMaxBplotData} 4 | \alias{.MLLMaxBplotData} 5 | \title{Prepare data for model plotting} 6 | \usage{ 7 | .MLLMaxBplotData( 8 | mll, 9 | nonLinModelQuoted, 10 | linModelQuoted, 11 | maxCover, 12 | data, 13 | averageCovariates = TRUE, 14 | observedAge = FALSE, 15 | plotCIs = TRUE 16 | ) 17 | } 18 | \arguments{ 19 | \item{mll}{outputs of an \code{bbmle::mle2} call (the fitted non-linear 20 | model), from which coefficient values will be extracted.} 21 | 22 | \item{nonLinModelQuoted}{The non-linear equation as a \code{call} 23 | (quoted expression) passed to \code{mle2(minuslog1)}. See \code{?mle}. 24 | Accepts equations with three parameters 'A', 'p' and 'k'.} 25 | 26 | \item{linModelQuoted}{A list of linear equations/modes relating each 27 | parameter ('A', 'p' and 'k') with a set of covariates. A \code{call} 28 | (quoted expression) passed to \code{mle2(..., parameters)}. Note that for the 29 | purpose of tree growth, the linear equation determining 'A' should include a 30 | 'cover' predictor indicating the tree cover or dominance in the stand. Should be 31 | scaled between 0 and \code{maxCover}.} 32 | 33 | \item{maxCover}{numeric. Value indicating maximum cover/dominance.} 34 | 35 | \item{data}{data for estimation of maximum biomass. Should contain at least 36 | an 'age' column. Note that other covariates will be averaged and 'cover' values 37 | will be replaced with the maximum cover value (\code{maxCover}).} 38 | 39 | \item{averageCovariates}{should covariates other than age/cover be averaged for 40 | biomass predictions? If not, for each age (at maximum cover) there will be as 41 | many predictions as other covariate values. If \code{observedAge == TRUE} and 42 | \code{averageCovariates == FALSE} then the original data is used, with cover 43 | changed to \code{maxCover}.} 44 | 45 | \item{observedAge}{should observed age values be used, or should these be generated 46 | as \code{round(seq(min(age), max(age)*1.5, length.out = 100), 0)}? If \code{observedAge == TRUE} and 47 | \code{averageCovariates == FALSE} then the original data is used, with cover 48 | changed to \code{maxCover}.} 49 | 50 | \item{plotCIs}{should confidence intervals be calculated and plotted?} 51 | } 52 | \description{ 53 | Prepare data for model plotting 54 | } 55 | \seealso{ 56 | \code{\link[bbmle:mle2]{bbmle::mle2()}} 57 | } 58 | -------------------------------------------------------------------------------- /man/dot-createCohortData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{.createCohortData} 4 | \alias{.createCohortData} 5 | \title{Generate template \code{cohortData} table} 6 | \usage{ 7 | .createCohortData( 8 | inputDataTable, 9 | sppColumns, 10 | minCoverThreshold = 5, 11 | doAssertion = getOption("LandR.assertions", TRUE), 12 | rescale = TRUE 13 | ) 14 | } 15 | \arguments{ 16 | \item{inputDataTable}{A \code{data.table} with columns described above.} 17 | 18 | \item{sppColumns}{A vector of the names of the columns in \code{inputDataTable} that 19 | represent percent cover by species, rescaled to sum up to 100\%\%.} 20 | 21 | \item{minCoverThreshold}{minimum total cover percentage necessary to consider the pixel 22 | vegetated, or a cohort present in a pixel.} 23 | 24 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 25 | ensure the function is running correctly. 26 | Default: \code{getOption("LandR.assertions", TRUE)}.} 27 | 28 | \item{rescale}{Logical. If \code{TRUE}, the default, cover for each species will be rescaled 29 | so all cover in \code{pixelGroup} or pixel sums to 100.} 30 | } 31 | \value{ 32 | \code{cohortData} (\code{data.table}) with attribute \code{"imputedPixID"} 33 | } 34 | \description{ 35 | Internal function used by \code{\link[=makeAndCleanInitialCohortData]{makeAndCleanInitialCohortData()}}. 36 | } 37 | \keyword{internal} 38 | -------------------------------------------------------------------------------- /man/dot-fitNLMwCovariates.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{.fitNLMwCovariates} 4 | \alias{.fitNLMwCovariates} 5 | \title{Fit non-linear growth model under various starting conditions} 6 | \usage{ 7 | .fitNLMwCovariates( 8 | data, 9 | nonLinModelQuoted, 10 | linModelQuoted, 11 | mllsOuterPrev, 12 | model = c("CR", "Logistic"), 13 | maxCover = 1L, 14 | starts = NULL, 15 | lower = NULL, 16 | upper = NULL, 17 | nbWorkers = 1L 18 | ) 19 | } 20 | \arguments{ 21 | \item{data}{a \code{data.table} or \code{data.frame} with all covariates 22 | and the response variable. Note that incomplete lines are removed.} 23 | 24 | \item{nonLinModelQuoted}{The non-linear equation as a \code{call} 25 | (quoted expression) passed to \code{bbmle::mle2(minuslog1)}. See \code{?mle}. 26 | Accepts equations with three parameters 'A', 'p' and 'k'.} 27 | 28 | \item{linModelQuoted}{A list of linear equations/modes relating each 29 | parameter ('A', 'p' and 'k') with a set of covariates. A \code{call} 30 | (quoted expression) passed to \code{mle2(..., parameters)}. Note that for the 31 | purpose of tree growth, the linear equation determining 'A' should include a 32 | 'cover' predictor indicating the tree cover or dominance in the stand. Should be 33 | scaled between 0 and \code{maxCover}.} 34 | 35 | \item{mllsOuterPrev}{the output of a previous \code{fitNLMwCovariates} run which 36 | is used to extract last best AIC and maximum biomass estimate and judge if new 37 | iterations are better.} 38 | 39 | \item{model}{character. Non-linear model form used to estimate average maximum 40 | biomass. One of "CR" (Chapman-Richards) or "Logistic". In both cases, maximum biomass 41 | is equivalent to the 'A' asymptote parameter, which is estimated using observed mean 42 | values of predictors entering its linear equation and \code{cover == maxCover}, if this 43 | predictor is included (as it should). Passed to \code{extractMaxB}} 44 | 45 | \item{maxCover}{numeric. Value indicating maximum cover/dominance.} 46 | 47 | \item{starts}{\code{data.table} or \code{data.frame} of parameter starting values. Will be coerced to named list 48 | with names being parameter names.} 49 | 50 | \item{lower}{passed to \link[bbmle:mle2]{bbmle::mle2}} 51 | 52 | \item{upper}{passed to \link[bbmle:mle2]{bbmle::mle2}} 53 | 54 | \item{nbWorkers}{integer. If > 1, the number of workers to use in \code{parallelly::makeClusterPSOCK(nbWorkers = .)}, 55 | otherwise no parallellisation is done.} 56 | } 57 | \value{ 58 | a \code{list} with entries \code{mll} (the maximum likelihood-estimated 59 | coefficients) and \code{AICbest} (the AIC of the best models generating these coefficients) 60 | } 61 | \description{ 62 | Uses likelihood parameter estimation to fit non linear models 63 | while attempting several starting values. 64 | } 65 | \seealso{ 66 | \code{\link[bbmle:mle2]{bbmle::mle2()}} 67 | } 68 | -------------------------------------------------------------------------------- /man/dot-getMaxBCoefs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{.getMaxBCoefs} 4 | \alias{.getMaxBCoefs} 5 | \title{Get maximum biomass coefficient names} 6 | \usage{ 7 | .getMaxBCoefs(mll, model = c("CR", "Logistic")) 8 | } 9 | \arguments{ 10 | \item{mll}{the output of an \code{bbmle::mle2} call (the fitted non-linear model), 11 | from which coefficient values will be extracted} 12 | 13 | \item{model}{character. Non-linear model form used to estimate average maximum 14 | biomass. One of "CR" (Chapman-Richards) or "Logistic".} 15 | } 16 | \value{ 17 | a list of two vectors of parameter names one following 18 | coefficient names in \code{mll} ('mllCoefNames'), the other using the original 19 | names as in the data used for model fitting ('origCoefNames') 20 | } 21 | \description{ 22 | Extracts the names of linear coefficients 23 | for the maximum-biomass-equivalent parameter in 24 | the non-linear growth equations 25 | } 26 | -------------------------------------------------------------------------------- /man/dot-interpolateLightProb.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{.interpolateLightProb} 4 | \alias{.interpolateLightProb} 5 | \title{Find interpolated value of light probability} 6 | \usage{ 7 | .interpolateLightProb(x, x0, x1, y0, y1) 8 | } 9 | \arguments{ 10 | \item{x}{the species shade tolerance trait value for which we want to find 11 | the interpolated probability.} 12 | 13 | \item{x0}{the \code{floor} of \code{x} corresponding to a class of shade 14 | tolerance in the \code{sufficientLight} table.} 15 | 16 | \item{x1}{the \code{ceiling} of \code{x} corresponding to a class of shade 17 | tolerance in the \code{sufficientLight} table.} 18 | 19 | \item{y0}{the probability of germination in the \code{sufficientLight} table 20 | corresponding to \code{x0}.} 21 | 22 | \item{y1}{the probability of germination in the \code{sufficientLight} table 23 | corresponding to \code{x1}.} 24 | } 25 | \value{ 26 | \code{vector} of the interpolated value 27 | } 28 | \description{ 29 | Find interpolated value of light probability 30 | } 31 | -------------------------------------------------------------------------------- /man/dot-logFloor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{.logFloor} 4 | \alias{.logFloor} 5 | \title{Log-transformed values, with a floor (> 0)} 6 | \usage{ 7 | .logFloor(x, floor = 0.3) 8 | } 9 | \arguments{ 10 | \item{x}{Numeric.} 11 | 12 | \item{floor}{Minimum age value boundary. Default \code{0.3}.} 13 | } 14 | \description{ 15 | Avoid \code{-Inf} problems when \code{x == 0} by setting a non-zero floor value for \code{x}. 16 | This is preferred over using some \code{log(x + d)} transformation, as the choice of \code{d} is 17 | arbitrary, and will affect model fit. 18 | } 19 | \examples{ 20 | \dontrun{ 21 | x <- sample(0:400, 1e7, replace = TRUE) 22 | floor <- 0.3 23 | logFloor <- log(floor) 24 | microbenchmark::microbenchmark( 25 | log(pmax(floor, x)), 26 | pmax(log(floor), log(x)), 27 | {x[x < floor] <- floor; log(x)}, 28 | {y <- log(x); y[is.infinite(y)] <- logFloor} ## fastest; TODO: implement? not a bottleneck 29 | ) 30 | } 31 | } 32 | \keyword{internal} 33 | -------------------------------------------------------------------------------- /man/dot-overlay.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{.overlay} 4 | \alias{.overlay} 5 | \title{Overlaying function} 6 | \usage{ 7 | .overlay( 8 | SPP, 9 | HQ, 10 | LQ, 11 | hqLarger, 12 | highQualityStack, 13 | lowQualityStack, 14 | outputFilenameSuffix = "overlay", 15 | destinationPath 16 | ) 17 | } 18 | \arguments{ 19 | \item{SPP}{\code{data.table} column of species layer name} 20 | 21 | \item{HQ}{\code{data.table} column of whether \code{SPP} is present in HQ layers} 22 | 23 | \item{LQ}{\code{data.table} column of whether \code{SPP} is present in LQ layers} 24 | 25 | \item{highQualityStack}{high quality list/stack of rasters 26 | (will be used preferentially)} 27 | 28 | \item{lowQualityStack}{low quality list/stack of rasters 29 | (will be used to fill \code{NA}s in \code{highQualityStack})} 30 | 31 | \item{outputFilenameSuffix}{file suffix to save raster if there was overlaying. 32 | Defaults to \code{"overlay"}.} 33 | 34 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 35 | } 36 | \description{ 37 | Used internally in \code{overlayStacks}. Function to be applied to each row 38 | of a \code{data.table} containing information of whether the species layer 39 | exists in the HQ and LQ data. 40 | Only overlays if data exists in both layers, otherwise returns the layer with data. 41 | } 42 | \keyword{internal} 43 | -------------------------------------------------------------------------------- /man/dot-speciesTableColNames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LANDIS-II-tables.R 3 | \docType{data} 4 | \name{.speciesTableRawColNames} 5 | \alias{.speciesTableRawColNames} 6 | \alias{.speciesTableColNames} 7 | \title{Species Table Column Names} 8 | \format{ 9 | An object of class \code{character} of length 18. 10 | 11 | An object of class \code{character} of length 18. 12 | } 13 | \usage{ 14 | .speciesTableRawColNames 15 | 16 | .speciesTableColNames 17 | } 18 | \description{ 19 | Species Table Column Names 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/dropTerm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{dropTerm} 4 | \alias{dropTerm} 5 | \title{Drop factor term including interactions from a model formula} 6 | \usage{ 7 | dropTerm(form, term) 8 | } 9 | \arguments{ 10 | \item{form}{A model formula.} 11 | 12 | \item{term}{Character vector giving the name of the term to drop.} 13 | } 14 | \value{ 15 | An updated model formula. 16 | } 17 | \description{ 18 | Based on \url{https://stackoverflow.com/a/23382097/1380598}. 19 | } 20 | -------------------------------------------------------------------------------- /man/dummy-inputs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/makeDummyInputs.R 3 | \name{makeDummyEcoregionMap} 4 | \alias{makeDummyEcoregionMap} 5 | \alias{makeDummyRawBiomassMap} 6 | \alias{makeDummyStandAgeMap} 7 | \alias{makeDummyRstLCC} 8 | \alias{makeDummyEcoregionFiles} 9 | \title{Create dummy inputs for test simulations} 10 | \usage{ 11 | makeDummyEcoregionMap(rasterToMatch) 12 | 13 | makeDummyRawBiomassMap(rasterToMatch) 14 | 15 | makeDummyStandAgeMap(rawBiomassMap) 16 | 17 | makeDummyRstLCC(rasterToMatch) 18 | 19 | makeDummyEcoregionFiles(ecoregionMap, rstLCC, rasterToMatch) 20 | } 21 | \arguments{ 22 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 23 | raster operations (i.e., the one used throughout the simulation).} 24 | 25 | \item{rawBiomassMap}{a \code{rawBiomassMap} (e.g. the one used 26 | throughout the simulation)} 27 | 28 | \item{ecoregionMap}{The \code{ecoregionMap}, a raster of all the unique ecoregion groupings, 29 | which group together pixels of similar biophysical characteristics.} 30 | 31 | \item{rstLCC}{raster of land-cover class, e.g., LCC2005} 32 | } 33 | \value{ 34 | a \code{RasterLayer} object or, in the case of \code{makeDummyEcoregionFiles}, a list. 35 | } 36 | \description{ 37 | \code{ecoregionMap}is a raster of all the unique groupings. 38 | } 39 | \details{ 40 | \code{rawBiomassMap} is a raster of "raw" total stand biomass per pixel, 41 | with values between 100 and 20000 g/m^2. 42 | 43 | \code{standAgeMap} is a raster of stand age per pixel (where biomass exists) 44 | with values between 1 and 300 years. 45 | 46 | \code{rstLCC} is a raster land-cover class per pixel, with values between 1 and 5 that have no 47 | correspondence to any real land-cover classes. 48 | 49 | \code{ecoregionFiles} uses dummy versions of \code{ecoregionMap} and \code{rstLCC} 50 | to create a list with two objects: the \code{ecoregionMap} and a table summarizing its 51 | information per \code{pixelID}. 52 | See \code{ecoregionProducer} (it uses \code{ecoregionProducer} internally). 53 | } 54 | -------------------------------------------------------------------------------- /man/ecoregionProducer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ecoregions.R 3 | \name{ecoregionProducer} 4 | \alias{ecoregionProducer} 5 | \title{Make \code{ecoregionMap} and \code{ecoregion} table} 6 | \usage{ 7 | ecoregionProducer(ecoregionMaps, ecoregionName = NULL, rasterToMatch) 8 | } 9 | \arguments{ 10 | \item{ecoregionMaps}{a \code{list} with two rasters, one with ecoregions (e.g. ecodistricts) 11 | and another with land cover (e.g. LCC).} 12 | 13 | \item{ecoregionName}{the name describing the type of ecoregions in first map 14 | (e.g. \code{"ecoDistrict"}) if passing a polygon file.} 15 | 16 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 17 | raster operations (i.e., the one used throughout the simulation).} 18 | } 19 | \value{ 20 | A list with two objects: the \code{ecoregionMap} and a table summarizing 21 | its information per \code{pixelID} 22 | } 23 | \description{ 24 | This function combines an ecoregion map and a land cover map (e.g. ecodistricts and LCC) 25 | and creates a map and table of containing their combined values and pixel IDs. 26 | Used internally in LandR modules to prepare maps for to make \code{cohortData}. 27 | } 28 | -------------------------------------------------------------------------------- /man/equivalentName.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/chooseName.R 3 | \name{equivalentName} 4 | \alias{equivalentName} 5 | \alias{equivalentNameColumn} 6 | \title{Return equivalent name from a \code{data.frame} of equivalencies} 7 | \usage{ 8 | equivalentName(value, df, column, multi = FALSE, searchColumn = NULL) 9 | 10 | equivalentNameColumn(value, df, column, multi = FALSE, searchColumn = NULL) 11 | } 12 | \arguments{ 13 | \item{value}{Vector of values to match in \code{df}.} 14 | 15 | \item{df}{A \code{data.frame} where every row is a set of equivalent names.} 16 | 17 | \item{column}{A character string or numeric of length 1, indicating the column 18 | in \code{df} to return names from.} 19 | 20 | \item{multi}{Logical. If \code{TRUE}, then all matches will be returned. 21 | Default \code{FALSE} for backwards compatibility. 22 | This may result in more elements than were in \code{value}, 23 | as each \code{value} may be matched by more than one entry, 24 | returning more than one result each from \code{column}. 25 | If a species is found in the \code{df}, but there is no corresponding 26 | value in \code{column}, it will return \code{NA}.} 27 | 28 | \item{searchColumn}{Optionally, provide the name of a column in \code{df} that results 29 | must be found in. The return value will still be from \code{column}} 30 | } 31 | \description{ 32 | This is simply a wrapper around \code{match} or \verb{\\\%in\\\%} for 33 | a specific \code{data.frame} of values. 34 | } 35 | -------------------------------------------------------------------------------- /man/extractMaxB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{extractMaxB} 4 | \alias{extractMaxB} 5 | \title{Maximum biomass estimator} 6 | \usage{ 7 | extractMaxB(mll, newdata, average = FALSE, model = c("CR", "Logistic")) 8 | } 9 | \arguments{ 10 | \item{mll}{the output of an \code{bbmle::mle2} call (the fitted non-linear model), 11 | from which coefficient values will be extracted} 12 | 13 | \item{newdata}{data for estimation of 'A'} 14 | 15 | \item{average}{should 'A' be estimated for average values of its predictors.} 16 | 17 | \item{model}{character. Non-linear model form used to estimate average maximum 18 | biomass. One of "CR" (Chapman-Richards) or "Logistic".} 19 | } 20 | \description{ 21 | Estimation of maximum biomass as the A parameter in the Chapman-Richards and 22 | Logistic growth equations. Since A is modelled as linear term, it is a matrix 23 | product of its linear coefficients. It is assumed that all coefficients are 24 | related additively. 25 | } 26 | -------------------------------------------------------------------------------- /man/fasterizeFromSp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{fasterizeFromSp} 4 | \alias{fasterizeFromSp} 5 | \title{Rasterize polygons using \code{fasterize}} 6 | \usage{ 7 | fasterizeFromSp(sp, raster, fieldName) 8 | } 9 | \arguments{ 10 | \item{sp}{a shapefile to rasterize} 11 | 12 | \item{raster}{the template raster to use} 13 | 14 | \item{fieldName}{the field to use (will be ignored if the shapefile has no fields)} 15 | } 16 | \value{ 17 | \code{RasterLayer} 18 | } 19 | \description{ 20 | Rasterize polygons using \code{fasterize} 21 | } 22 | -------------------------------------------------------------------------------- /man/genPGsPostDisturbance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/disturbances.R 3 | \name{genPGsPostDisturbance} 4 | \alias{genPGsPostDisturbance} 5 | \title{Re-generate new \code{pixelGroup}s in partially disturbed pixels.} 6 | \usage{ 7 | genPGsPostDisturbance( 8 | cohortData, 9 | pixelGroupMap, 10 | disturbedPixelTable, 11 | disturbedPixelCohortData, 12 | colsForPixelGroups = LandR::columnsForPixelGroups, 13 | doAssertion = getOption("LandR.assertions", TRUE) 14 | ) 15 | } 16 | \arguments{ 17 | \item{cohortData}{\code{data.table}. The pre-disturbance \code{cohortData} table} 18 | 19 | \item{pixelGroupMap}{\code{SpatRaster}. The pre-disturbance \code{pixelGroupMap}.} 20 | 21 | \item{disturbedPixelTable}{\code{data.table}. A table with at least the \code{pixelIndex} 22 | of all disturbed pixels. Additional columns are ignored.} 23 | 24 | \item{disturbedPixelCohortData}{a \code{cohortData}-like table with information of dead, 25 | and surviving, but \emph{NOT} regenerating cohorts (cohorts for whom regeneration via, e.g., serotiny 26 | or resprouting was successfully activated), in \emph{disturbed pixels only}. Dead cohorts should 27 | age B == 0, surviving cohorts B > 0.} 28 | 29 | \item{colsForPixelGroups}{character. \code{cohortData} columns used to find identical pixels in terms of 30 | cohort composition, and group them into \code{pixelGroups}.} 31 | 32 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 33 | ensure the function is running correctly. 34 | Default: \code{getOption("LandR.assertions", TRUE)}.} 35 | } 36 | \value{ 37 | a named list with: 38 | \itemize{ 39 | \item a \code{cohortData} table with the updated \code{pixelGroups}, as well as 40 | survivor cohorts, but not dead cohorts. 41 | \item a \code{pixelGroupMap} with the updated \code{pixelGroups} in disturbed pixels 42 | } 43 | } 44 | \description{ 45 | Re-generate new \code{pixelGroup}s in partially disturbed pixels. 46 | } 47 | \details{ 48 | This function regenerates \code{pixelGroup}s in situations where 49 | disturbances are not stand-replacing and create survivor and dead 50 | cohorts in some, but potentially not all, pixels of a \code{pixelGroup}. This is 51 | necessary to prevent reintroducing dead cohorts that were not affected 52 | in the other pixels of the same, original, \code{pixelGroup}. 53 | \strong{ATTENTION} This function alone will not generate final \code{pixelGroups}, 54 | and will likely need to be followed by an \code{updateCohortData} run. 55 | The function: 56 | \enumerate{ 57 | \item creates a table of undisturbed pixels, and disturbed pixels with dead and surviving cohorts 58 | but not new cohorts (e.g. from serotiny/resprouting) -- these are added by \code{updateCohortData}; 59 | \item generates \code{pixelGroups} considering these dead and surviving cohorts -- this ensures that 60 | we account for cohorts that died in some but not all pixels of a given \code{pixelGroup}; 61 | \item then removes dead cohorts (as they should not be in tables for downstream 62 | functions like \code{updateCohortData}) and recalculates \code{pixelGroups} -- this ensures that 63 | pixels that became similar/dissimilar after the death of some cohorts can form new \code{pixelGroups}. 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /man/generatePixelGroups.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{generatePixelGroups} 4 | \alias{generatePixelGroups} 5 | \title{Add the correct \code{pixelGroups} to a \code{pixelDataTable} object} 6 | \usage{ 7 | generatePixelGroups( 8 | pixelDataTable, 9 | maxPixelGroup, 10 | columns = c("ecoregionGroup", "speciesCode", "age", "B") 11 | ) 12 | } 13 | \arguments{ 14 | \item{pixelDataTable}{A \code{data.table} with column-based descriptions. 15 | Must have a column called \code{pixelIndex}, which allows for multiple rows to be associated 16 | with a single pixel.} 17 | 18 | \item{maxPixelGroup}{A length 1 numeric indicating the current maximum \code{pixelGroup} value; 19 | the \code{pixelGroup} numbers returned will start at \code{maxPixelGroup + 1}.} 20 | 21 | \item{columns}{A character vector of column names to use as part of the generation of unique 22 | combinations of features. Default is \code{c("ecoregionGroup", "speciesCode", "age", "B")}} 23 | } 24 | \value{ 25 | Returns a vector of \code{pixelGroup} in the original order of the input \code{pixelDataTable}. 26 | This should likely be added to the \code{pixelDataTable} object immediately. 27 | } 28 | \description{ 29 | Generates unique groupings of a \code{data.table} object where one or more rows can 30 | all belong to the same \code{pixelIndex}. Pixel groups will be identical pixels based 31 | on unique combinations of \code{columns}. 32 | } 33 | -------------------------------------------------------------------------------- /man/genericExtract.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/terra-raster-utils.R 3 | \name{genericExtract} 4 | \alias{genericExtract} 5 | \title{Generic extract points} 6 | \usage{ 7 | genericExtract(x, y, field = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{x}{a raster or polygon object (\code{sp}, \code{raster} or \code{terra})} 11 | 12 | \item{y}{a points or polygons spatial object (\code{sp}, \code{sf}, or \code{terra})} 13 | 14 | \item{field}{character. The field(s) to extract when x is a polygon. 15 | If \code{NULL}, all fields are extracted and returned. IDs of y are always returned (\code{ID} column).} 16 | 17 | \item{...}{passed to \code{\link[terra:extract]{terra::extract()}}} 18 | } 19 | \value{ 20 | a \code{data.table} with extracted values and an \code{ID} column of y point IDs 21 | } 22 | \description{ 23 | Extracts points from raster layers using the original raster layer projection. 24 | } 25 | \details{ 26 | If \code{x} and \code{y} are both polygons, \code{extract} often outputs \code{NA} due to misalignments 27 | (this can happen even when \code{x == y}), even after \code{snap(y, x)}. 28 | To circumvent this problem, \code{intersect} is used internally and, 29 | if the \code{extract} argument \code{fun} is passed, it is applied to values of \code{y} per polygon ID of \code{x}. 30 | } 31 | -------------------------------------------------------------------------------- /man/getWildfire_NFI.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/wildfire.R 3 | \name{getWildfire_NFI} 4 | \alias{getWildfire_NFI} 5 | \title{Download and prepare raster fire data from NFI} 6 | \usage{ 7 | getWildfire_NFI(dPath, rasterToMatch, url = NULL) 8 | } 9 | \arguments{ 10 | \item{dPath}{destination path for archive} 11 | 12 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 13 | raster operations (i.e., the one used throughout the simulation).} 14 | 15 | \item{url}{location from which to download the wildfire raster layer(s)} 16 | } 17 | \value{ 18 | a raster with values representing fire year 1985-2015 19 | } 20 | \description{ 21 | Download and prepare raster fire data from NFI 22 | } 23 | -------------------------------------------------------------------------------- /man/ggplotMLL_maxB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{ggplotMLL_maxB} 4 | \alias{ggplotMLL_maxB} 5 | \title{Plot estimated maximum biomass by age} 6 | \usage{ 7 | ggplotMLL_maxB( 8 | mll, 9 | data, 10 | maxCover = 1L, 11 | xCovar = "age", 12 | plotTitle = NULL, 13 | nonLinModelQuoted, 14 | linModelQuoted, 15 | averageCovariates = TRUE, 16 | observedAge = FALSE, 17 | plotCIs = TRUE 18 | ) 19 | } 20 | \arguments{ 21 | \item{mll}{a named list with outputs of an \code{bbmle::mle2} call (the fitted non-linear 22 | model), from which coefficient values will be extracted. If several model outputs 23 | are provided all fitted models will be plotted, with plot labels corresponding to list names.} 24 | 25 | \item{data}{data for estimation of maximum biomass. Should contain at least 26 | an 'age' column. Note that other covariates will be averaged and 'cover' values 27 | will be replaced with the maximum cover value (\code{maxCover}). If \code{mll} is a list 28 | data is assumed to be the same for the two models.} 29 | 30 | \item{maxCover}{numeric. Value indicating maximum cover/dominance.} 31 | 32 | \item{xCovar}{the variable shown in the x axis. Defaults to \code{age}.} 33 | 34 | \item{plotTitle}{character. Passed to \code{title} in \code{\link[ggplot2:labs]{ggplot2::labs()}}.} 35 | 36 | \item{nonLinModelQuoted}{a named list of non-linear equations as a \code{call} 37 | (quoted expression) passed to \code{mle2(minuslog1)}. See \code{\link[bbmle:mle2]{bbmle::mle2()}}. 38 | Accepts equations with three parameters 'A', 'p' and 'k'. List names and 39 | length must the same as in \code{mll}.} 40 | 41 | \item{linModelQuoted}{A named list of lists of linear equations/modes relating each 42 | parameter ('A', 'p' and 'k') with a set of covariates. A \code{call} 43 | (quoted expression) passed to \code{mle2(..., parameters)}. Note that for the 44 | purpose of tree growth, the linear equation determining 'A' should include a 45 | 'cover' predictor indicating the tree cover or dominance in the stand. Should be 46 | scaled between 0 and \code{maxCover}. List names and length must the same as in \code{mll}.} 47 | 48 | \item{averageCovariates}{should covariates other than age/cover be averaged for 49 | biomass predictions? If not, for each age (at maximum cover) there will be as 50 | many predictions as other covariate values. If \code{observedAge == TRUE} and 51 | \code{averageCovariates == FALSE} then the original data is used, with cover 52 | changed to \code{maxCover}.} 53 | 54 | \item{observedAge}{should observed age values be used, or should these be generated 55 | as \code{round(seq(min(age), max(age)*1.5, length.out = 100), 0)}? If \code{observedAge == TRUE} and 56 | \code{averageCovariates == FALSE} then the original data is used, with cover 57 | changed to \code{maxCover}.} 58 | 59 | \item{plotCIs}{should confidence intervals be calculated and plotted?} 60 | } 61 | \description{ 62 | Plots a maximum biomass estimated at maximum 'cover' (or dominance) levels as a function of age. 63 | } 64 | -------------------------------------------------------------------------------- /man/installBioSIM.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biosim.R 3 | \name{installBioSIM} 4 | \alias{installBioSIM} 5 | \title{Install \pkg{BioSIM} to retrieve climate and other projections using \code{BioSIM}} 6 | \usage{ 7 | installBioSIM(lib) 8 | } 9 | \arguments{ 10 | \item{lib}{ 11 | character vector giving the library directories where to 12 | install the packages. Recycled as needed. If missing, defaults to 13 | the first element of \code{\link{.libPaths}()}. 14 | } 15 | } 16 | \description{ 17 | Install \pkg{BioSIM} to retrieve climate and other projections using \code{BioSIM} 18 | } 19 | -------------------------------------------------------------------------------- /man/landisIIrepo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LANDIS-II-tables.R 3 | \docType{data} 4 | \name{landisIIrepo} 5 | \alias{landisIIrepo} 6 | \title{Default LANDIS-II project repo url} 7 | \format{ 8 | An object of class \code{character} of length 1. 9 | } 10 | \usage{ 11 | landisIIrepo 12 | } 13 | \description{ 14 | Default LANDIS-II project repo url 15 | } 16 | \keyword{internal} 17 | -------------------------------------------------------------------------------- /man/loadCASFRI.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepSpeciesLayers.R 3 | \name{loadCASFRI} 4 | \alias{loadCASFRI} 5 | \title{Load CASFRI data} 6 | \usage{ 7 | loadCASFRI( 8 | CASFRIRas, 9 | attrFile, 10 | headerFile, 11 | sppEquiv, 12 | sppEquivCol, 13 | type = c("cover", "age") 14 | ) 15 | } 16 | \arguments{ 17 | \item{CASFRIRas}{TODO: description needed} 18 | 19 | \item{attrFile}{TODO: description needed} 20 | 21 | \item{headerFile}{TODO: description needed} 22 | 23 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 24 | See \code{data("sppEquivalencies_CA", "LandR")}. 25 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 26 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 27 | 28 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 29 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 30 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 31 | 32 | \item{type}{Character string. Either \code{"cover"} or \code{"age"}.} 33 | } 34 | \value{ 35 | TODO: description needed 36 | } 37 | \description{ 38 | TODO: description needed 39 | } 40 | -------------------------------------------------------------------------------- /man/loadkNNSpeciesLayers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{loadkNNSpeciesLayers} 4 | \alias{loadkNNSpeciesLayers} 5 | \title{Load kNN species layers from online data repository} 6 | \usage{ 7 | loadkNNSpeciesLayers( 8 | dPath, 9 | rasterToMatch = NULL, 10 | studyArea = NULL, 11 | sppEquiv, 12 | year = 2001, 13 | knnNamesCol = "KNN", 14 | sppEquivCol = "Boreal", 15 | thresh = 10, 16 | url = NULL, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{dPath}{path to the data directory} 22 | 23 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 24 | raster operations (i.e., the one used throughout the simulation).} 25 | 26 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 27 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 28 | 29 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 30 | See \code{data("sppEquivalencies_CA", "LandR")}. 31 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 32 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 33 | 34 | \item{year}{which year's layers should be retrieved? One of 2001 (default) or 2011.} 35 | 36 | \item{knnNamesCol}{character string indicating the column in \code{sppEquiv} 37 | containing kNN species names. 38 | Default \code{"KNN"} for when \code{sppEquivalencies_CA} is used.} 39 | 40 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 41 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 42 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 43 | 44 | \item{thresh}{the minimum percent cover a species must have (per pixel) 45 | to be considered present in the study area. 46 | Defaults to 10.} 47 | 48 | \item{url}{the source url for the data, default is KNN 2011 dataset 49 | (\url{https://ftp.maps.canada.ca/pub/nrcan_rncan/Forests_Foret/canada-forests-attributes_attributs-forests-canada/2011-attributes_attributs-2011/})} 50 | 51 | \item{...}{Additional arguments passed to \code{\link[reproducible:Cache]{reproducible::Cache()}} 52 | and \code{\link[=equivalentName]{equivalentName()}}. Also valid: \code{outputPath}, and \code{studyAreaName}.} 53 | } 54 | \value{ 55 | A raster stack of percent cover layers by species. 56 | } 57 | \description{ 58 | TODO: description needed 59 | } 60 | -------------------------------------------------------------------------------- /man/makeAndCleanInitialCohortData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{makeAndCleanInitialCohortData} 4 | \alias{makeAndCleanInitialCohortData} 5 | \title{Generate initial \code{cohortData} table} 6 | \usage{ 7 | makeAndCleanInitialCohortData( 8 | inputDataTable, 9 | sppColumns, 10 | imputeBadAgeModel = quote(lme4::lmer(age ~ B * speciesCode + cover * speciesCode + (1 | 11 | initialEcoregionCode))), 12 | minCoverThreshold, 13 | doAssertion = getOption("LandR.assertions", TRUE), 14 | doSubset = TRUE 15 | ) 16 | } 17 | \arguments{ 18 | \item{inputDataTable}{A \code{data.table} with columns described above.} 19 | 20 | \item{sppColumns}{A vector of the names of the columns in \code{inputDataTable} that 21 | represent percent cover by species, rescaled to sum up to 100\%\%.} 22 | 23 | \item{imputeBadAgeModel}{statistical model used to impute ages in pixels with missing 24 | data or with cover == 0. If set to NULL no imputation will be attempted, and pixels with 25 | missing age are excluded.} 26 | 27 | \item{minCoverThreshold}{minimum total cover percentage necessary to consider the pixel 28 | vegetated, or a cohort present in a pixel.} 29 | 30 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 31 | ensure the function is running correctly. 32 | Default: \code{getOption("LandR.assertions", TRUE)}.} 33 | 34 | \item{doSubset}{Turns on/off subsetting. Defaults to \code{TRUE}.} 35 | } 36 | \value{ 37 | a \code{cohortData} \code{data.table} with attribute \code{"imputedPixID"} 38 | (a vector of pixel IDs that suffered imputation). 39 | } 40 | \description{ 41 | Takes a single \code{data.table} input, which has the following columns in addition to 42 | others that will be labelled with species name, and contain percent cover of each: 43 | } 44 | \details{ 45 | \itemize{ 46 | \item \code{pixelIndex} (integer) 47 | \item \code{age} (integer) 48 | \item \code{logAge} (numeric) 49 | \item \code{initialEcoregionCode} (factor) 50 | \item \code{totalBiomass} (integer) 51 | \item \code{lcc} (integer) 52 | \item \code{rasterToMatch} (integer) 53 | \item \code{speciesCode} (factor) 54 | \item \code{cover} (integer) 55 | \item \code{coverOrig} (integer) 56 | \item \code{B} (integer) 57 | } 58 | 59 | Several data correction/imputation operations are also performed. Namely, age is imputed 60 | in pixels where age data is missing (but not cover) and where \code{cover == 0} but \code{age > 0}, 61 | total biomass is zeroed if \code{age == 0}, and age is zeroed if \code{biomass == 0}. 62 | } 63 | \author{ 64 | Eliot McIntire 65 | } 66 | -------------------------------------------------------------------------------- /man/makeBiomassMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{makeBiomassMap} 4 | \alias{makeBiomassMap} 5 | \title{Create \code{biomassMap}} 6 | \usage{ 7 | makeBiomassMap(pixelCohortData, rasterToMatch) 8 | } 9 | \arguments{ 10 | \item{pixelCohortData}{The full \code{cohortData} \code{data.table}} 11 | 12 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 13 | raster operations (i.e., the one used throughout the simulation).} 14 | } 15 | \value{ 16 | The \code{biomassMap}, a raster of total stand biomass per pixel. 17 | } 18 | \description{ 19 | This is a function that creates the \code{biomassMap} raster used for simulations in 20 | \code{Biomass_core} module, using estimated data based on \code{rawBiomassMap} contained in 21 | \code{pixelCohortData}. 22 | } 23 | -------------------------------------------------------------------------------- /man/makeEcoregionDT.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ecoregions.R 3 | \name{makeEcoregionDT} 4 | \alias{makeEcoregionDT} 5 | \title{Make the \code{ecoregion} table} 6 | \usage{ 7 | makeEcoregionDT(pixelCohortData, speciesEcoregion) 8 | } 9 | \arguments{ 10 | \item{pixelCohortData}{The full \code{cohortData} \code{data.table}} 11 | 12 | \item{speciesEcoregion}{A \code{data.table} with \code{species}-\code{ecoregion}-specific species trait values. 13 | Ecoregion refers to "ecolocation", a categorical variable grouping sites with similar biophysical 14 | characteristics. The table should have at least the following columns: \code{speciesCode} and 15 | \code{ecoregionGroup}, character representation of species and ecoregion groups respectively, 16 | \code{maxB} the maximum biomass for the species in a given 'ecoregion', \code{maxANPP} the maximum 17 | aboveground net primary productivity and \code{SEP} the species establishment probability. 18 | May contain columns \code{inflationFactor} (used to adjust \code{maxB}) and \code{mANPPproportion} 19 | (used to calculate \code{maxANPP}).} 20 | } 21 | \value{ 22 | A \code{data.table} with ecoregion codes and their active status per \code{pixelID}. 23 | } 24 | \description{ 25 | This function creates a table containing pixel-wise ecoregion codes and whether they 26 | are "active" (have biomass > 0) or not for simulation. Unlike \code{ecoregionProducer}, 27 | this function creates the \code{ecoregion} table from pixel information contained in 28 | \code{pixelCohortData} 29 | } 30 | -------------------------------------------------------------------------------- /man/makeEcoregionMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ecoregions.R 3 | \name{makeEcoregionMap} 4 | \alias{makeEcoregionMap} 5 | \title{Make the \code{ecoregionMap} raster} 6 | \usage{ 7 | makeEcoregionMap(ecoregionFiles, pixelCohortData) 8 | } 9 | \arguments{ 10 | \item{ecoregionFiles}{A list with two objects: the \code{ecoregionMap} and a table summarizing 11 | its information per \code{pixelID}.} 12 | 13 | \item{pixelCohortData}{The full \code{cohortData} \code{data.table}} 14 | } 15 | \value{ 16 | A raster with ecoregion codes. 17 | } 18 | \description{ 19 | Creates a raster of ecoregion codes per pixel. 20 | Unlike \code{ecoregionProducer}, this fills the raster with pixel information contained in 21 | \code{pixelCohortData}. 22 | } 23 | -------------------------------------------------------------------------------- /man/makeMinRelativeB.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{makeMinRelativeB} 4 | \alias{makeMinRelativeB} 5 | \title{Create \code{minRelativeB} table} 6 | \usage{ 7 | makeMinRelativeB(pixelCohortData) 8 | } 9 | \arguments{ 10 | \item{pixelCohortData}{The full \code{cohortData} \code{data.table}} 11 | } 12 | \value{ 13 | a data.frame of min relative biomass values per ecoregion group. 14 | } 15 | \description{ 16 | The table contains expert-based values for minimum relative biomass of each shade tolerance 17 | class (the minimum relative biomass a cohort with a given shade tolerance should have to be able 18 | to germinate), in each unique ecoregion group. 19 | All ecoregion groups currently have the same values. 20 | } 21 | -------------------------------------------------------------------------------- /man/makePickellStack.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepSpeciesLayers.R 3 | \name{makePickellStack} 4 | \alias{makePickellStack} 5 | \title{\code{makePickellStack}} 6 | \usage{ 7 | makePickellStack(PickellRaster, sppEquiv, sppEquivCol, destinationPath) 8 | } 9 | \arguments{ 10 | \item{PickellRaster}{TODO: description needed} 11 | 12 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 13 | See \code{data("sppEquivalencies_CA", "LandR")}. 14 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 15 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 16 | 17 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 18 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 19 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 20 | 21 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 22 | } 23 | \value{ 24 | TODO: description needed 25 | } 26 | \description{ 27 | TODO: description and title needed 28 | } 29 | -------------------------------------------------------------------------------- /man/makePixelGroupMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{makePixelGroupMap} 4 | \alias{makePixelGroupMap} 5 | \title{Create \code{makePixelGroupMap}} 6 | \usage{ 7 | makePixelGroupMap(pixelCohortData, rasterToMatch) 8 | } 9 | \arguments{ 10 | \item{pixelCohortData}{The full \code{cohortData} \code{data.table}} 11 | 12 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 13 | raster operations (i.e., the one used throughout the simulation).} 14 | } 15 | \value{ 16 | a raster with pixel groups 17 | } 18 | \description{ 19 | Create the \code{makePixelGroupMap} raster containing \code{pixelGroups} in \code{pixelCohortData}. 20 | } 21 | -------------------------------------------------------------------------------- /man/makePixelTable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{makePixelTable} 4 | \alias{makePixelTable} 5 | \title{Make \code{pixelTable} from biomass, age, land-cover and species cover data} 6 | \usage{ 7 | makePixelTable( 8 | speciesLayers, 9 | standAgeMap, 10 | ecoregionFiles, 11 | biomassMap, 12 | rasterToMatch, 13 | rstLCC, 14 | printSummary = TRUE, 15 | doAssertion = getOption("LandR.assertions", TRUE) 16 | ) 17 | } 18 | \arguments{ 19 | \item{speciesLayers}{A \code{RasterStack} or \code{RasterLayer} that 20 | should contain species cover data in the study area} 21 | 22 | \item{standAgeMap}{A \code{rasterLayer} of stand ages with attribute \code{"imputedPixID"}} 23 | 24 | \item{ecoregionFiles}{A list with two objects: the \code{ecoregionMap} and a table summarizing 25 | its information per \code{pixelID.} See \code{ecoregionProducer}.} 26 | 27 | \item{biomassMap}{raster of total stand biomass in t/ha. Biomass units are 28 | converted to g/m^2.} 29 | 30 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 31 | raster operations (i.e., the one used throughout the simulation).} 32 | 33 | \item{rstLCC}{raster of land-cover class, e.g., LCC2005} 34 | 35 | \item{printSummary}{Logical. If \code{TRUE}, the default, a print out of the 36 | \code{summary(pixelTable)} will occur.} 37 | 38 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 39 | ensure the function is running correctly. 40 | Default: \code{getOption("LandR.assertions", TRUE)}.} 41 | } 42 | \value{ 43 | A \code{data.table} as many rows as non-NA pixels in \code{rasterToMath} and 44 | the columns containing pixel data from the input raster layers, with 45 | biomass in g/m^2. 46 | } 47 | \description{ 48 | Make \code{pixelTable} from biomass, age, land-cover and species cover data 49 | } 50 | -------------------------------------------------------------------------------- /man/mergeSppRaster.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{mergeSppRaster} 4 | \alias{mergeSppRaster} 5 | \title{Merge species percent-cover rasters} 6 | \usage{ 7 | mergeSppRaster(sppMerge, speciesLayers, sppEquiv, column, suffix, dPath, ...) 8 | } 9 | \arguments{ 10 | \item{sppMerge}{TODO} 11 | 12 | \item{speciesLayers}{A \code{RasterStack} or \code{RasterLayer} that 13 | should contain species cover data in the study area} 14 | 15 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 16 | See \code{data("sppEquivalencies_CA", "LandR")}. 17 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 18 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 19 | 20 | \item{column}{TODO} 21 | 22 | \item{suffix}{TODO} 23 | 24 | \item{dPath}{destination path TODO} 25 | 26 | \item{...}{Additional arguments TODO} 27 | } 28 | \description{ 29 | Used internally in \code{overlayStacks}. 30 | } 31 | \keyword{internal} 32 | -------------------------------------------------------------------------------- /man/minRelativeBDefaults.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{minRelativeBDefaults} 4 | \alias{minRelativeBDefaults} 5 | \title{minRelativeB defaults for Western Boreal Forest Canada} 6 | \usage{ 7 | minRelativeBDefaults() 8 | } 9 | \description{ 10 | minRelativeB defaults for Western Boreal Forest Canada 11 | } 12 | -------------------------------------------------------------------------------- /man/modifySpeciesAndSpeciesEcoregionTable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maxBestimation.R 3 | \name{modifySpeciesAndSpeciesEcoregionTable} 4 | \alias{modifySpeciesAndSpeciesEcoregionTable} 5 | \title{Update \code{species} and \code{speciesEcoregion} tables} 6 | \usage{ 7 | modifySpeciesAndSpeciesEcoregionTable(speciesEcoregion, speciesTable) 8 | } 9 | \arguments{ 10 | \item{speciesEcoregion}{A \code{data.table} with \code{species}-\code{ecoregion}-specific species trait values. 11 | Ecoregion refers to "ecolocation", a categorical variable grouping sites with similar biophysical 12 | characteristics. The table should have at least the following columns: \code{speciesCode} and 13 | \code{ecoregionGroup}, character representation of species and ecoregion groups respectively, 14 | \code{maxB} the maximum biomass for the species in a given 'ecoregion', \code{maxANPP} the maximum 15 | aboveground net primary productivity and \code{SEP} the species establishment probability. 16 | May contain columns \code{inflationFactor} (used to adjust \code{maxB}) and \code{mANPPproportion} 17 | (used to calculate \code{maxANPP}).} 18 | 19 | \item{speciesTable}{A species traits table, with \strong{at least} the following columns: 20 | \itemize{ 21 | \item \code{speciesCode} an character representation of species; 22 | \item \code{Area} a character of geographical area within a species range for which trait values are relevant; 23 | \item \code{longevity} species longevity in years, \code{sexualmature} age in years at sexual maturity; 24 | \item \code{shadetolerance} numeric value between 1-5 of relative shade tolerance (with respect to other species); 25 | \item \code{seeddistance_eff} the "effective" seed dispersal distance; 26 | \item \code{seeddistance_max} a numeric with the maximum seed dispersal distance; 27 | \item \code{mortalityshape} and \code{growthcurve}: growth curve shape parameters. 28 | Other columns (e.g. fire-related traits) can also be included depending on LandR modules in use. 29 | Please see the LANDIS-II Biomass Succession Extension v3.2.1 manual (Scheller and Miranda 2015) 30 | for further detail. 31 | }} 32 | } 33 | \value{ 34 | a \code{list} with modified \code{speciesEcoregion} and \code{speciesTable}, 35 | under the names "newSpeciesEcoregion" and "newSpeciesTable", respectively. 36 | } 37 | \description{ 38 | Update \code{species} and \code{speciesEcoregion} tables 39 | } 40 | -------------------------------------------------------------------------------- /man/nonForestedPixels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{nonForestedPixels} 4 | \alias{nonForestedPixels} 5 | \title{Assess non-forested pixels based on species cover data and land-cover} 6 | \usage{ 7 | nonForestedPixels( 8 | speciesLayers, 9 | omitNonTreedPixels, 10 | forestedLCCClasses, 11 | rstLCC 12 | ) 13 | } 14 | \arguments{ 15 | \item{speciesLayers}{A \code{RasterStack} or \code{RasterLayer} that 16 | should contain species cover data in the study area} 17 | 18 | \item{omitNonTreedPixels}{logical. Should pixels with classes in \code{forestedLCCClasses} be 19 | included as non-forested?} 20 | 21 | \item{forestedLCCClasses}{vector of non-forested land-cover classes in \code{rstLCC}} 22 | 23 | \item{rstLCC}{raster of land-cover class, e.g., LCC2005} 24 | } 25 | \value{ 26 | a logical vector of length \code{ncell(rstLCC)} 27 | where \code{TRUE} indicates non-forested pixels where there is no 28 | species cover data, or a non-forested land-cover class 29 | } 30 | \description{ 31 | Assess non-forested pixels based on species cover data and land-cover 32 | } 33 | -------------------------------------------------------------------------------- /man/overlayLCCs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/overlayLCCs.R 3 | \name{overlayLCCs} 4 | \alias{overlayLCCs} 5 | \title{Overlay different LCC data sources} 6 | \usage{ 7 | overlayLCCs( 8 | LCCs, 9 | forestedList, 10 | outputLayer, 11 | NAcondition, 12 | NNcondition, 13 | remapTable = NULL, 14 | classesToReplace, 15 | availableERC_by_Sp, 16 | forestEquivalencies = NULL 17 | ) 18 | } 19 | \arguments{ 20 | \item{LCCs}{A named list or named \code{RasterStack} of layers whose content 21 | is Land Cover Class.} 22 | 23 | \item{forestedList}{A named list of same length and names as \code{LCCs} indicating 24 | which classes in each LCC raster are 'forested', either permanent or transient} 25 | 26 | \item{outputLayer}{A character string that matches one of the named elements 27 | in \code{LCCs}. This will be the classification system returned.} 28 | 29 | \item{NAcondition}{The condition when a pixel is deemed to be \code{NA}. 30 | Given as a character string of a vectorized logical statement that will be 31 | within the \code{forestEquivalencies} table. 32 | It should be a set of conditions with \verb{== 0}, i.e., non-forested. 33 | Examples:, e.g., \code{"LCC2005 == 0"} or \code{"CC == 0 | LCC2005 == 0"}, 34 | where \code{0} is the non-forested pixels based on converting LCCs and 35 | \code{forestedList} to \code{1} and \code{0}.} 36 | 37 | \item{NNcondition}{The 'nearest-neighbour' condition; i.e., the condition when 38 | a nearest-neighbour search is done to fill in the pixel with forested type. 39 | Given as a character string of a vectorized logical statement that will be 40 | parsed within the \code{forestEquivalencies} table. 41 | It should be a set of conditions with \verb{== 0}, i.e., non-forested. 42 | Examples:, e.g., \code{"LCC2005 == 0"} or \code{"CC == 0 | LCC2005 == 0"}, 43 | where \code{0} is the non-forested pixels based on converting LCCs and 44 | \code{forestedList} to \code{1} and \code{0}.} 45 | 46 | \item{remapTable}{\code{data.table}. This would be for a situation where 47 | 2 LCC layers are provided, one has information in a pixel, but not the one 48 | which is \code{outputLayer}, so this needs a reclassify or remap.} 49 | 50 | \item{classesToReplace}{Passed to \code{\link[=convertUnwantedLCC]{convertUnwantedLCC()}}, for the pixels where 51 | \code{NNcondition} is \code{TRUE}} 52 | 53 | \item{availableERC_by_Sp}{Passed to \code{\link[=convertUnwantedLCC]{convertUnwantedLCC()}}, for the pixels where 54 | \code{NNcondition} is \code{TRUE}. If this is \code{NULL}, then it will be 55 | created internally with all pixels with: 56 | \code{data.table(initialEcoregionCode = LCCs[[outputLayer]][])}} 57 | 58 | \item{forestEquivalencies}{A \code{data.frame} or \code{NULL}. 59 | If \code{NULL}, this function will derive this table automatically from the 60 | other arguments. Otherwise, the user must provide a \code{data.frame} with 61 | \code{length(LCCs) + 1} columns, and \code{2 ^ length(LCCs)} rows. 62 | Currently not used.} 63 | } 64 | \description{ 65 | Overlay different LCC data sources 66 | } 67 | \author{ 68 | Eliot McIntire and Alex Chubaty 69 | } 70 | -------------------------------------------------------------------------------- /man/overlayStacks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{overlayStacks} 4 | \alias{overlayStacks} 5 | \title{Overlay layers within raster stacks} 6 | \usage{ 7 | overlayStacks( 8 | highQualityStack, 9 | lowQualityStack, 10 | outputFilenameSuffix = "overlay", 11 | destinationPath 12 | ) 13 | } 14 | \arguments{ 15 | \item{highQualityStack}{high quality list/stack of rasters 16 | (will be used preferentially)} 17 | 18 | \item{lowQualityStack}{low quality list/stack of rasters 19 | (will be used to fill \code{NA}s in \code{highQualityStack})} 20 | 21 | \item{outputFilenameSuffix}{file suffix to save raster if there was overlaying. 22 | Defaults to \code{"overlay"}.} 23 | 24 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 25 | } 26 | \description{ 27 | Overlays rasters of different data resolution by filling in gaps in the highest 28 | resolution raster with data available in lowest resolution one. 29 | If only high or low resolution data are available, it will use it without 30 | attempting to overlay. 31 | } 32 | -------------------------------------------------------------------------------- /man/partitionBiomass.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/partitionBiomass.R 3 | \name{partitionBiomass} 4 | \alias{partitionBiomass} 5 | \title{Partition biomass according to cover estimates} 6 | \usage{ 7 | partitionBiomass(x = 1, pixelCohortData) 8 | } 9 | \arguments{ 10 | \item{x}{The ratio for deciduous cover:biomass, where conifer cover:biomass = 1} 11 | 12 | \item{pixelCohortData}{A full \code{pixelCohortData} object (i.e., not \code{cohortData})} 13 | } 14 | \description{ 15 | This function will partition \code{totalBiomass} into each cohort. 16 | It will discount deciduous cover, if \code{x < 1}. 17 | } 18 | -------------------------------------------------------------------------------- /man/pixelFate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{pixelFate} 4 | \alias{pixelFate} 5 | \title{Create or amend data to a \code{pixelFateDT} object} 6 | \usage{ 7 | pixelFate( 8 | pixelFateDT, 9 | fate = NA_character_, 10 | pixelsRemoved = 0, 11 | runningPixelTotal = NA_integer_ 12 | ) 13 | } 14 | \arguments{ 15 | \item{pixelFateDT}{A \code{pixelFateDT} \code{data.table} with 3 columns: \code{fate}, 16 | \code{pixelsRemoted}, and \code{runningPixelTotal}.} 17 | 18 | \item{fate}{A character string (length 1) describing in words the change} 19 | 20 | \item{pixelsRemoved}{A numeric indicating how many pixels were removed due to the \code{fate}.} 21 | 22 | \item{runningPixelTotal}{an optional numeric with new, running total. If not supplied, 23 | it will be calculated from the last row of \code{pixelFateDT} \code{runningTotal} minus the 24 | \code{pixelsRemoved}} 25 | } 26 | \value{ 27 | A \code{pixelFateDT} object, updated with one extra row. 28 | } 29 | \description{ 30 | Create or amend data to a \code{pixelFateDT} object 31 | } 32 | -------------------------------------------------------------------------------- /man/pkgEnv.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz.R 3 | \docType{data} 4 | \name{.pkgEnv} 5 | \alias{.pkgEnv} 6 | \title{The \code{LandR} package environment} 7 | \format{ 8 | An object of class \code{environment} of length 0. 9 | } 10 | \usage{ 11 | .pkgEnv 12 | } 13 | \description{ 14 | Environment used internally to store internal package objects and methods. 15 | } 16 | \keyword{internal} 17 | -------------------------------------------------------------------------------- /man/plantNewCohorts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{plantNewCohorts} 4 | \alias{plantNewCohorts} 5 | \title{Create new cohorts based on provenance table with unique \code{pixelGroup} and add to \code{cohortData}} 6 | \usage{ 7 | plantNewCohorts( 8 | newPixelCohortData, 9 | cohortData, 10 | pixelGroupMap, 11 | initialB = 10, 12 | currentTime, 13 | successionTimestep, 14 | trackPlanting = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{newPixelCohortData}{the cohorts that were harvested} 19 | 20 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 21 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 22 | 23 | \item{pixelGroupMap}{A \code{RasterLayer} with pixel values equal to a pixel group 24 | number that corresponds exactly to \code{pixelGroup} column in \code{cohortData}.} 25 | 26 | \item{initialB}{the initial biomass of new cohorts. Defaults to ten.} 27 | 28 | \item{currentTime}{The current simulation time e.g., \code{time(sim)}.} 29 | 30 | \item{successionTimestep}{The time between successive seed dispersal events. 31 | In LANDIS-II, this is called "Succession Timestep".} 32 | 33 | \item{trackPlanting}{adds column that tracks planted cohorts if \code{TRUE}} 34 | } 35 | \value{ 36 | A \code{data.table} with a new \code{cohortData} 37 | } 38 | \description{ 39 | Create new cohorts based on provenance table with unique \code{pixelGroup} and add to \code{cohortData} 40 | } 41 | -------------------------------------------------------------------------------- /man/plotLeadingSpecies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot_summaries.R 3 | \name{plotLeadingSpecies} 4 | \alias{plotLeadingSpecies} 5 | \title{Leading species plots} 6 | \usage{ 7 | plotLeadingSpecies( 8 | studyAreaName, 9 | climateScenario, 10 | Nreps, 11 | years, 12 | outputDir, 13 | treeSpecies, 14 | defineLeading = .defineLeading, 15 | leadingPercentage = 0.8, 16 | treeType = NULL, 17 | rasterToMatch 18 | ) 19 | } 20 | \arguments{ 21 | \item{studyAreaName}{character string giving the study area name} 22 | 23 | \item{climateScenario}{character string specifying the name of a CIMP6 climate scenario, 24 | including SSP, formatted as in \code{ClimateNA}, using underscores as separator 25 | (e.g., 'CanESM5_SSP370').} 26 | 27 | \item{Nreps}{the number of simulation replicates/run used to produce summary figures. 28 | NOTE: \code{mclapply} is used internally, so you should set \code{options(mc.cores = nReps)} 29 | to take advantage of parallel processing.} 30 | 31 | \item{years}{TODO} 32 | 33 | \item{outputDir}{Path specifying the directory to which outputs figures/objects should be saved.} 34 | 35 | \item{treeSpecies}{TODO} 36 | 37 | \item{defineLeading}{TODO} 38 | 39 | \item{leadingPercentage}{TODO} 40 | 41 | \item{treeType}{TODO} 42 | 43 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 44 | raster operations (i.e., the one used throughout the simulation).} 45 | } 46 | \value{ 47 | list of file names corresponding to the figures and/or objects written to disk 48 | 49 | list of filepaths corresponding to the images and/or objects written to disk 50 | } 51 | \description{ 52 | Plot effects on conifer-to-deciduous or deciduous-to-conifer conversions. 53 | } 54 | -------------------------------------------------------------------------------- /man/plotSpatial.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/terra-raster-utils.R 3 | \name{plotSpatial} 4 | \alias{plotSpatial} 5 | \title{Create a \code{ggplot} of a raster or \code{sf} object.} 6 | \usage{ 7 | plotSpatial(x, plotTitle, limits = NULL, field = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{\code{SpatRaster}, \code{RasterLayer}, \code{SpatVector} or \code{sf} object} 11 | 12 | \item{plotTitle}{character. A title for the plot passed to \code{ggplot::labs(title = plotTitle)}.} 13 | 14 | \item{limits}{TODO} 15 | 16 | \item{field}{character. If \code{x} is \code{sf} or \code{SpatVector}, a field to plot.} 17 | } 18 | \description{ 19 | Can be used with \code{SpaDES.core::Plots}. 20 | } 21 | -------------------------------------------------------------------------------- /man/plotVTM.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plotVTM} 4 | \alias{plotVTM} 5 | \title{Summary plots of leading vegetation types} 6 | \usage{ 7 | plotVTM( 8 | speciesStack = NULL, 9 | vtm = NULL, 10 | vegLeadingProportion = 0.8, 11 | sppEquiv, 12 | sppEquivCol, 13 | colors, 14 | title = "Leading vegetation types" 15 | ) 16 | } 17 | \arguments{ 18 | \item{speciesStack}{A \code{SpatRaster}, \code{RasterStack} or \code{RasterBrick} 19 | of percent-cover-by-species layers.} 20 | 21 | \item{vtm}{An optional vegetation type map (\code{RasterLayer} or \code{SpatRaster}). 22 | If not supplied, will be produced internally by \code{makeVegTypeMap}.} 23 | 24 | \item{vegLeadingProportion}{Numeric between 0-1, determining the relative biomass 25 | threshold a species needs to pass to be considered "leading".} 26 | 27 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 28 | See \code{data("sppEquivalencies_CA", "LandR")}. 29 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 30 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 31 | 32 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 33 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 34 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 35 | 36 | \item{colors}{Named vector of colour codes, named using species names. NOTE: 37 | plot order will follow this order.} 38 | 39 | \item{title}{The title to use for the generated plots.} 40 | } 41 | \description{ 42 | Create raster of leading vegetation types and \code{Plot} a bar chart summary 43 | and a vegetation type map. NOTE: plot order will follow \code{colors} order. 44 | } 45 | \author{ 46 | Eliot McIntire 47 | } 48 | -------------------------------------------------------------------------------- /man/prepEcoregions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepEcoregions.R 3 | \name{prepEcoregions} 4 | \alias{prepEcoregions} 5 | \title{Prepare ecoregions objects} 6 | \usage{ 7 | prepEcoregions( 8 | ecoregionRst = NULL, 9 | ecoregionLayer, 10 | ecoregionLayerField = NULL, 11 | rasterToMatchLarge, 12 | rstLCCAdj, 13 | pixelsToRm, 14 | cacheTags 15 | ) 16 | } 17 | \arguments{ 18 | \item{ecoregionRst}{an optional raster object that could be passed to \code{sim}, 19 | representing ecoregions} 20 | 21 | \item{ecoregionLayer}{an \code{sf} polygons object representing ecoregions} 22 | 23 | \item{ecoregionLayerField}{optional. The field in \code{ecoregionLayer} that represents ecoregions.} 24 | 25 | \item{rasterToMatchLarge}{the \code{rasterToMatchLarge} object from \code{sim}} 26 | 27 | \item{rstLCCAdj}{\code{RasterLayer} representing land cover adjusted for non-forest classes} 28 | 29 | \item{pixelsToRm}{a vector of pixels to remove} 30 | 31 | \item{cacheTags}{\code{UserTags} to pass to cache} 32 | } 33 | \description{ 34 | Prepare ecoregions objects 35 | } 36 | -------------------------------------------------------------------------------- /man/prepEcozonesRst.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ecozones.R 3 | \name{prepEcozonesRst} 4 | \alias{prepEcozonesRst} 5 | \title{Prepare ecozones raster} 6 | \usage{ 7 | prepEcozonesRst(url, destinationPath, studyArea = NULL, rasterToMatch = NULL) 8 | } 9 | \arguments{ 10 | \item{url}{character. ecozones shapefile url. 11 | Default: \url{http://sis.agr.gc.ca/cansis/nsdb/ecostrat/zone/ecozone_shp.zip}.} 12 | 13 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 14 | 15 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 16 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 17 | 18 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 19 | raster operations (i.e., the one used throughout the simulation).} 20 | } 21 | \value{ 22 | \code{RasterLayer} 23 | } 24 | \description{ 25 | Download, rasterize, crop, mask, and reproject Canadian national ecozones shapefile. 26 | } 27 | -------------------------------------------------------------------------------- /man/prepInputsCanDEM.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dem.R 3 | \name{prepInputsCanDEM} 4 | \alias{prepInputsCanDEM} 5 | \title{Get digital elevation map of Canada} 6 | \usage{ 7 | prepInputsCanDEM(studyArea, rasterToMatch, destinationPath) 8 | } 9 | \arguments{ 10 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 11 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 12 | 13 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 14 | raster operations (i.e., the one used throughout the simulation).} 15 | 16 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 17 | } 18 | \value{ 19 | \code{RasterLayer} 20 | } 21 | \description{ 22 | Defaults to using 3 arcmin DEM of Canada in lonlat. 23 | } 24 | -------------------------------------------------------------------------------- /man/prepInputsEcoregion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LANDIS-II-tables.R 3 | \name{prepInputsEcoregion} 4 | \alias{prepInputsEcoregion} 5 | \title{Prepare ecoregion table} 6 | \usage{ 7 | prepInputsEcoregion(url = NULL, dPath, cacheTags = NULL) 8 | } 9 | \arguments{ 10 | \item{url}{If NULL (the default), uses one from the LANDIS-II project: 11 | \url{https://github.com/LANDIS-II-Foundation/Extensions-Succession/master/biomass-succession-archive/trunk/tests/v6.0-2.0/ecoregion.txt"}).} 12 | 13 | \item{dPath}{The destination path.} 14 | 15 | \item{cacheTags}{User tags to pass to \code{Cache}.} 16 | } 17 | \value{ 18 | A \code{data.table} 19 | } 20 | \description{ 21 | Get the dummy ecoregion table from LANDIS-II examples. 22 | } 23 | -------------------------------------------------------------------------------- /man/prepInputsFireYear.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{prepInputsFireYear} 4 | \alias{prepInputsFireYear} 5 | \title{Create a raster of fire perimeters} 6 | \usage{ 7 | prepInputsFireYear(..., rasterToMatch, fireField = "YEAR", earliestYear = 1950) 8 | } 9 | \arguments{ 10 | \item{...}{Additional arguments passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}} 11 | 12 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 13 | raster operations (i.e., the one used throughout the simulation).} 14 | 15 | \item{fireField}{field used to rasterize fire polys} 16 | 17 | \item{earliestYear}{the earliest fire date to allow} 18 | } 19 | \value{ 20 | a \code{SpatRaster} layer of fire perimeters with fire year values. 21 | } 22 | \description{ 23 | Create a raster of fire perimeters 24 | } 25 | \examples{ 26 | library(SpaDES.tools) 27 | library(terra) 28 | library(reproducible) 29 | 30 | options("reproducible.useTerra" = TRUE, "reproducible.rasterRead" = "terra::rast") 31 | 32 | targetCRS <- crs(randomStudyArea()) 33 | randomPoly <- randomStudyArea( 34 | center = vect(cbind(-115, 50), crs = targetCRS), 35 | size = 1e+7, 36 | ) 37 | buffExt <- buffer(randomPoly, 1e+3) |> ext() 38 | ras2match <- rast(res = 10, ext = ext(randomPoly), crs = crs(randomPoly)) 39 | ras2match <- rasterize(randomPoly, ras2match) 40 | 41 | firePerimeters <- prepInputsFireYear( 42 | url = paste0("https://cwfis.cfs.nrcan.gc.ca/downloads", 43 | "/nfdb/fire_poly/current_version/NFDB_poly.zip"), 44 | destinationPath = tempdir(), 45 | rasterToMatch = ras2match, 46 | earliestYear = 1930 47 | ) 48 | 49 | if (interactive()) { 50 | plot(firePerimeters) 51 | plot(randomPoly, add = TRUE) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /man/prepInputsLCC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{prepInputsLCC} 4 | \alias{prepInputsLCC} 5 | \title{Simple \code{prepInputs} for Canadian LCC data} 6 | \usage{ 7 | prepInputsLCC( 8 | year = 2010, 9 | destinationPath = asPath("."), 10 | method = c("ngb", "near"), 11 | filename2 = NULL, 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{year}{Numeric, either 2010 or 2015. See note re: backwards compatibility for 2005.} 17 | 18 | \item{destinationPath}{Character string of a directory in which to download 19 | and save the file that comes from \code{url} and is also where the function 20 | will look for \code{archive} or \code{targetFile}. NOTE (still experimental): 21 | To prevent repeated downloads in different locations, the user can also set 22 | \code{options("reproducible.inputPaths")} to one or more local file paths to 23 | search for the file before attempting to download. Default for that option is 24 | \code{NULL} meaning do not search locally.} 25 | 26 | \item{method}{passed to \link[terra:intersect]{terra::intersect} or \link[raster:intersect]{raster::intersect}, 27 | and \link[reproducible:prepInputs]{reproducible::prepInputs}} 28 | 29 | \item{filename2}{passed to \link[reproducible:prepInputs]{reproducible::prepInputs}} 30 | 31 | \item{...}{Arguments passed to \code{terra::mask} (for \code{maskTo}), \code{terra::project} (for \code{projectTo}) 32 | or \code{terra::writeRaster} (for \code{writeTo}) and not used for \code{cropTo}, as well \code{postProcess}'s 33 | \code{rasterToMatch} and \code{studyArea} arguments (see below). Commonly used arguments might be 34 | \code{method}, \code{touches}, and \code{datatype}. If \code{filename} is passed, it will be ignored; use 35 | \verb{writeTo = }. If \code{reproducible.gdalwarp = TRUE}, then these will be passed to the 36 | \verb{gdal*} functions. See them for details.} 37 | } 38 | \description{ 39 | A wrapper around \code{prepInputs} for the Canadian Land Cover Classification product(s). 40 | } 41 | \note{ 42 | As of May 2021, NRCAN no longer provides/hosts the LCC2005 data. 43 | A privately hosted version of the data is available to maintain backwards compatibility, 44 | but new users/projects should use the 2010 (or newer) data. 45 | } 46 | -------------------------------------------------------------------------------- /man/prepInputsSpecies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LANDIS-II-tables.R 3 | \name{prepInputsSpecies} 4 | \alias{prepInputsSpecies} 5 | \alias{prepInputsMainInput} 6 | \title{Download and prepare a species traits table for use with \code{Biomass_core} module} 7 | \usage{ 8 | prepInputsSpecies(url = NULL, dPath, cacheTags = NULL) 9 | 10 | prepInputsMainInput(url = NULL, dPath = tempdir(), cacheTags = NULL) 11 | } 12 | \arguments{ 13 | \item{url}{If NULL (the default), uses one from the LANDIS-II project: 14 | \url{https://github.com/LANDIS-II-Foundation/Extensions-Succession/master/biomass-succession-archive/trunk/tests/v6.0-2.0/biomass-succession_test.txt"}).} 15 | 16 | \item{dPath}{The destination path.} 17 | 18 | \item{cacheTags}{User tags to pass to \code{Cache}.} 19 | } 20 | \value{ 21 | A \code{data.table} with columns ... TODO 22 | } 23 | \description{ 24 | TODO: add detailed description 25 | } 26 | \note{ 27 | This one is tailored to Canadian forests (?) 28 | } 29 | -------------------------------------------------------------------------------- /man/prepInputsSpeciesEcoregion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/LANDIS-II-tables.R 3 | \name{prepInputsSpeciesEcoregion} 4 | \alias{prepInputsSpeciesEcoregion} 5 | \title{Prepare species ecoregion table} 6 | \usage{ 7 | prepInputsSpeciesEcoregion(url = NULL, dPath, cacheTags = NULL) 8 | } 9 | \arguments{ 10 | \item{url}{If NULL (the default), uses one from the LANDIS-II project: 11 | \url{https://github.com/LANDIS-II-Foundation/Extensions-Succession/master/biomass-succession-archive/trunk/tests/v6.0-2.0/biomass-succession-dynamic-inputs_test.txt"}).} 12 | 13 | \item{dPath}{The destination path.} 14 | 15 | \item{cacheTags}{User tags to pass to \code{Cache}.} 16 | } 17 | \value{ 18 | A \code{data.table} 19 | } 20 | \description{ 21 | Get the dummy ecoregion table from LANDIS-II examples. 22 | } 23 | -------------------------------------------------------------------------------- /man/prepInputs_NTEMS_LCC_FAO.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputs_NTEMS.R 3 | \name{prepInputs_NTEMS_LCC_FAO} 4 | \alias{prepInputs_NTEMS_LCC_FAO} 5 | \title{Obtain an LCC layer for a given year from NTEMS, with forest matching the FAO definition} 6 | \usage{ 7 | prepInputs_NTEMS_LCC_FAO(year = 2010, disturbedCode = 1, ...) 8 | } 9 | \arguments{ 10 | \item{year}{stack of species layers rasters} 11 | 12 | \item{disturbedCode}{value assigned to pixels that are forest per FAO definition but not in LCC year} 13 | 14 | \item{...}{passed to \code{prepInputs}} 15 | } 16 | \value{ 17 | a \code{SpatRaster} with corrected forest pixels 18 | } 19 | \description{ 20 | Obtain an LCC layer for a given year from NTEMS, with forest matching the FAO definition 21 | } 22 | -------------------------------------------------------------------------------- /man/prepInputs_NTEMS_Nonforest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputs_NTEMS.R 3 | \name{prepInputs_NTEMS_Nonforest} 4 | \alias{prepInputs_NTEMS_Nonforest} 5 | \title{Reclassify non-flammable pixels that become flammable - herbaceous or shrubby - vegetation} 6 | \usage{ 7 | prepInputs_NTEMS_Nonforest( 8 | rstLCC, 9 | endYear = 2019, 10 | lccToAdjust = 33, 11 | nonforestLCC = c(50, 100), 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{rstLCC}{input lcc layer with bare soil class that may become vegetated} 17 | 18 | \item{endYear}{NTEMS LCC year to use for correcting transition from bare to non-forest} 19 | 20 | \item{lccToAdjust}{lcc values of the bare class} 21 | 22 | \item{nonforestLCC}{allowable lcc values for bare to become} 23 | 24 | \item{...}{non-spatial arguments passed to \code{prepInputs} e.g. \code{destinationPath}} 25 | } 26 | \value{ 27 | a \code{SpatRaster} with non-flammable pixels corrected if they become flammable non-forest 28 | } 29 | \description{ 30 | Reclassify non-flammable pixels that become flammable - herbaceous or shrubby - vegetation 31 | } 32 | -------------------------------------------------------------------------------- /man/prepRasterToMatch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{prepRasterToMatch} 4 | \alias{prepRasterToMatch} 5 | \title{Create \code{rasterToMatch} and \code{rasterToMatchLarge}} 6 | \usage{ 7 | prepRasterToMatch( 8 | studyArea, 9 | studyAreaLarge, 10 | rasterToMatch, 11 | rasterToMatchLarge, 12 | destinationPath, 13 | templateRas, 14 | studyAreaName, 15 | cacheTags 16 | ) 17 | } 18 | \arguments{ 19 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 20 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 21 | 22 | \item{studyAreaLarge}{same as \code{studyArea}, but larger and completely 23 | covering it.} 24 | 25 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 26 | raster operations (i.e., the one used throughout the simulation).} 27 | 28 | \item{rasterToMatchLarge}{the \code{rasterToMatchLarge} object from \code{sim}} 29 | 30 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 31 | 32 | \item{templateRas}{a template raster used to make \code{rasterToMatch} 33 | and/or \code{rasterToMatchLarge}. Must match \code{studyAreaLarge}.} 34 | 35 | \item{studyAreaName}{character string giving the study area name.} 36 | 37 | \item{cacheTags}{a character vector of strings to pass to \code{Cache(userTags)}} 38 | } 39 | \description{ 40 | \code{rasterToMatch} and \code{rasterToMatchLarge} raster layers are created 41 | from \code{studyArea} and \code{studyAreaLarge} polygons (respectively) 42 | using a template raster (often \code{rawBiomassMap}) 43 | } 44 | -------------------------------------------------------------------------------- /man/prepRawBiomassMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{prepRawBiomassMap} 4 | \alias{prepRawBiomassMap} 5 | \title{Create \code{rawBiomassMap}} 6 | \usage{ 7 | prepRawBiomassMap(studyAreaName, cacheTags, ...) 8 | } 9 | \arguments{ 10 | \item{studyAreaName}{character string giving the study area name.} 11 | 12 | \item{cacheTags}{a character vector of strings to pass to \code{Cache(userTags)}} 13 | 14 | \item{...}{arguments passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}} and \code{\link[reproducible:Cache]{reproducible::Cache()}}. If the following arguments 15 | are not provided, the following values will be used: 16 | \itemize{ 17 | \item{\code{url}: by default, the 2001 kNN stand biomass map is downloaded from 18 | the NRCan National Forest Inventory} 19 | \item{\code{useSAcrs} and \code{projectTo}: \code{FALSE} and \code{NA}} 20 | \item{\code{method}: \code{"bilinear"}} 21 | \item{\code{datatype}: \code{"INT2U"}} 22 | \item{\code{filename2}: \code{suffix("rawBiomassMap.tif", paste0("_", studyAreaName))}} 23 | \item{\code{overwrite}: \code{TRUE}} 24 | \item{\code{userTags}: \code{c(cacheTags, "rawBiomassMap")}} 25 | \item{\code{omitArgs}: \code{c("destinationPath", "targetFile", "userTags", "stable")}} 26 | }} 27 | } 28 | \value{ 29 | a \code{rawBiomassMap} raster 30 | } 31 | \description{ 32 | Create the \code{rawBiomassMap} raster containing biomass estimates for 33 | \code{pixelCohortData}. 34 | Wrapper on \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}} that will rasterize fire polygons. 35 | } 36 | -------------------------------------------------------------------------------- /man/prepSpeciesLayers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepSpeciesLayers.R 3 | \name{prepSpeciesLayers_KNN} 4 | \alias{prepSpeciesLayers_KNN} 5 | \alias{prepSpeciesLayers_CASFRI} 6 | \alias{prepSpeciesLayers_Pickell} 7 | \alias{prepSpeciesLayers_ForestInventory} 8 | \alias{prepSpeciesLayers_MBFRI} 9 | \alias{prepSpeciesLayers_ONFRI} 10 | \title{Prepare species layers} 11 | \usage{ 12 | prepSpeciesLayers_KNN( 13 | destinationPath, 14 | outputPath, 15 | url = NULL, 16 | studyArea, 17 | rasterToMatch, 18 | sppEquiv, 19 | sppEquivCol, 20 | thresh = 10, 21 | ... 22 | ) 23 | 24 | prepSpeciesLayers_CASFRI( 25 | destinationPath, 26 | outputPath, 27 | url = NULL, 28 | studyArea, 29 | rasterToMatch, 30 | sppEquiv, 31 | sppEquivCol, 32 | ... 33 | ) 34 | 35 | prepSpeciesLayers_Pickell( 36 | destinationPath, 37 | outputPath, 38 | url = NULL, 39 | studyArea, 40 | rasterToMatch, 41 | sppEquiv, 42 | sppEquivCol, 43 | ... 44 | ) 45 | 46 | prepSpeciesLayers_ForestInventory( 47 | destinationPath, 48 | outputPath, 49 | url = NULL, 50 | studyArea, 51 | rasterToMatch, 52 | sppEquiv, 53 | sppEquivCol, 54 | ... 55 | ) 56 | 57 | prepSpeciesLayers_MBFRI( 58 | destinationPath, 59 | outputPath, 60 | url = NULL, 61 | studyArea, 62 | rasterToMatch, 63 | sppEquiv, 64 | sppEquivCol, 65 | ... 66 | ) 67 | 68 | prepSpeciesLayers_ONFRI( 69 | destinationPath, 70 | outputPath, 71 | url = NULL, 72 | studyArea, 73 | rasterToMatch, 74 | sppEquiv, 75 | sppEquivCol, 76 | ... 77 | ) 78 | } 79 | \arguments{ 80 | \item{destinationPath}{path to data directory where objects will be downloaded or saved to} 81 | 82 | \item{outputPath}{TODO: description needed} 83 | 84 | \item{url}{if \code{NULL}, the default, use the default source url} 85 | 86 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 87 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 88 | 89 | \item{rasterToMatch}{A \code{RasterLayer} objects to use as the template for all subsequent 90 | raster operations (i.e., the one used throughout the simulation).} 91 | 92 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 93 | See \code{data("sppEquivalencies_CA", "LandR")}. 94 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 95 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 96 | 97 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 98 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 99 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 100 | 101 | \item{thresh}{threshold \\% cover used to defined the species as "present" in the study area. 102 | If at least one pixel has \code{cover >= thresh} , the species is considered "present". 103 | Otherwise the raster is excluded from the output. Defaults to 10.} 104 | 105 | \item{...}{other arguments, used for compatibility with other \code{prepSpeciesLayers} functions.} 106 | } 107 | \value{ 108 | TODO: description needed 109 | } 110 | \description{ 111 | TODO: description needed 112 | } 113 | -------------------------------------------------------------------------------- /man/randomStudyArea.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/studyArea.R 3 | \name{randomStudyArea} 4 | \alias{randomStudyArea} 5 | \title{Create default study areas for use with LandR modules} 6 | \usage{ 7 | randomStudyArea(center = NULL, size = 10000, seed = NULL) 8 | } 9 | \arguments{ 10 | \item{center}{\code{SpatialPoints} object specifying a set of coordinates and 11 | a projection. Default is an area in southern Alberta, Canada.} 12 | 13 | \item{size}{Numeric specifying the approximate size of the area in m^2. 14 | Default \code{1e4}.} 15 | 16 | \item{seed}{Numeric indicating the random seed to set internally 17 | (useful for ensuring the same study area is produced each time).} 18 | } 19 | \description{ 20 | This simply re-exports \code{SpaDES.tools::randomStudyArea} 21 | } 22 | -------------------------------------------------------------------------------- /man/rasterRead.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/terra-raster-utils.R 3 | \name{rasterRead} 4 | \alias{rasterRead} 5 | \title{Wrapper to read a raster using a specific package function} 6 | \usage{ 7 | rasterRead(...) 8 | } 9 | \arguments{ 10 | \item{...}{passed to \code{\link[terra:rast]{terra::rast()}} or \code{\link[raster:raster]{raster::raster()}}} 11 | } 12 | \value{ 13 | a raster of the type returned by the function 14 | } 15 | \description{ 16 | Evaluates the function given by the option \code{reproducible.rasterRead}. 17 | E.g., \code{terra::rast} or \code{raster::raster}. 18 | } 19 | \details{ 20 | TODO: Move to \code{reproducible} 21 | } 22 | -------------------------------------------------------------------------------- /man/rasterTerraHelpers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/terra-raster-utils.R 3 | \name{.NAvalueFlag} 4 | \alias{.NAvalueFlag} 5 | \alias{.stack} 6 | \alias{.projectExtent} 7 | \alias{asInt} 8 | \alias{isInt} 9 | \alias{reclass} 10 | \title{Set NA values in \code{Raster} or \code{SpatRaster}} 11 | \usage{ 12 | .NAvalueFlag(ras, NAval) 13 | 14 | .stack(rasList) 15 | 16 | .projectExtent(ras, crs) 17 | 18 | asInt(ras) 19 | 20 | isInt(ras) 21 | 22 | reclass(ras, tab) 23 | } 24 | \arguments{ 25 | \item{ras}{a \code{Raster}, or \code{SpatRaster} object} 26 | 27 | \item{NAval}{the value to use as \code{NA}} 28 | 29 | \item{rasList}{a list of \code{Raster} or \code{SpatRaster} objects} 30 | 31 | \item{crs}{passed to \code{raster::projectRaster(..., crs = crs)} and \code{terra::project(..., y = crs)}} 32 | 33 | \item{tab}{matrix of values to reclassify. See \code{terra::classify} and \code{raster::reclassify}.} 34 | } 35 | \value{ 36 | a raster with attributed NA values 37 | 38 | a stacked raster 39 | 40 | the projected extent 41 | 42 | \code{asInt} returns a \verb{*Raster} with values converted to \code{integer}, if they weren't already. 43 | 44 | \code{isInt} returns a logical as per \code{is.integer}. 45 | 46 | \code{reclass} returns a \verb{*Raster} with values reclassified as per \code{terra::classify} 47 | and \code{raster::reclassify}. 48 | } 49 | \description{ 50 | These all create a single function that can be used for either \code{Raster} or \code{SpatRaster} objects. 51 | } 52 | -------------------------------------------------------------------------------- /man/replaceAgeInFires.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/prepInputObjects.R 3 | \name{replaceAgeInFires} 4 | \alias{replaceAgeInFires} 5 | \title{Replace stand age with time since last fire} 6 | \usage{ 7 | replaceAgeInFires(standAgeMap, firePerimeters, startTime) 8 | } 9 | \arguments{ 10 | \item{standAgeMap}{a raster layer stand age map} 11 | 12 | \item{firePerimeters}{the earliest fire date to allow} 13 | 14 | \item{startTime}{date of the last fire year to be considered (e.g., start of fire 15 | period counting backwards). If missing, last fire year available will be used.} 16 | } 17 | \value{ 18 | a raster layer stand age map corrected for fires, with an attribute vector of pixel IDs 19 | for which ages were corrected. If no corrections were applied the attribute vector is \code{integer(0)}. 20 | } 21 | \description{ 22 | Replace stand age with time since last fire 23 | } 24 | \examples{ 25 | \dontrun{ 26 | library(SpaDES.tools) 27 | library(terra) 28 | library(reproducible) 29 | randomPoly <- vect(randomStudyArea(size = 1e7)) 30 | randomPoly 31 | ras2match <- rast(res = 250, ext = ext(randomPoly), crs = crs(randomPoly)) 32 | ras2match <- rasterize(randomPoly, ras2match) 33 | tempDir <- tempdir() 34 | 35 | standAge <- prepInputsStandAgeMap(destinationPath = tempDir, 36 | rasterToMatch = ras2match, 37 | fireURL = NA) ## or NULL 38 | attr(standAge, "imputedPixID") 39 | 40 | firePerimeters <- Cache(prepInputsFireYear, 41 | url = paste0("https://cwfis.cfs.nrcan.gc.ca/downloads", 42 | "/nfdb/fire_poly/current_version/NFDB_poly.zip"), 43 | destinationPath = tempDir, 44 | rasterToMatch = ras2match) 45 | standAge <- replaceAgeInFires(standAge, firePerimeters) 46 | attr(standAge, "imputedPixID") 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /man/resample.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{.resample} 4 | \alias{.resample} 5 | \title{Resample} 6 | \usage{ 7 | .resample(x, ...) 8 | } 9 | \description{ 10 | Imports the non-exported function \code{SpaDES.tools:::resample}. 11 | } 12 | \seealso{ 13 | \code{\link[SpaDES.tools:resample]{SpaDES.tools::resample()}} 14 | } 15 | \keyword{internal} 16 | -------------------------------------------------------------------------------- /man/rescale.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/makeDummyInputs.R 3 | \name{rescale} 4 | \alias{rescale} 5 | \title{Rescale function (as in \code{scales::rescale})} 6 | \usage{ 7 | rescale(x, to) 8 | } 9 | \arguments{ 10 | \item{x}{a \code{numeric} vector} 11 | 12 | \item{to}{a \code{numeric} vector of length 2. The new range of values.} 13 | } 14 | \description{ 15 | This is a simple function copied from the \code{scales} package (almost the same). 16 | } 17 | -------------------------------------------------------------------------------- /man/rmMissingCohorts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{rmMissingCohorts} 4 | \alias{rmMissingCohorts} 5 | \title{Remove missing cohorts from \code{cohortData} based on \code{pixelGroupMap}} 6 | \usage{ 7 | rmMissingCohorts( 8 | cohortData, 9 | pixelGroupMap, 10 | cohortDefinitionCols = c("pixelGroup", "age", "speciesCode"), 11 | doAssertion = getOption("LandR.assertions", TRUE) 12 | ) 13 | } 14 | \arguments{ 15 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 16 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 17 | 18 | \item{pixelGroupMap}{A \code{RasterLayer} with pixel values equal to a pixel group 19 | number that corresponds exactly to \code{pixelGroup} column in \code{cohortData}.} 20 | 21 | \item{cohortDefinitionCols}{the columns in \code{cohortData} that define unique cohorts} 22 | 23 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 24 | ensure the function is running correctly. 25 | Default: \code{getOption("LandR.assertions", TRUE)}.} 26 | } 27 | \value{ 28 | A \code{list} with 2 \code{data.table} objects, \code{cohortData} and \code{pixelGroupMap}, 29 | each updated based on missing \code{pixelGroups} in the other. 30 | } 31 | \description{ 32 | Remove missing cohorts from \code{cohortData} based on \code{pixelGroupMap} 33 | } 34 | -------------------------------------------------------------------------------- /man/scheduleDisturbance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/misc.R 3 | \name{scheduleDisturbance} 4 | \alias{scheduleDisturbance} 5 | \title{Test whether disturbance should be scheduled} 6 | \usage{ 7 | scheduleDisturbance(disturbanceLayer, currentYear) 8 | } 9 | \arguments{ 10 | \item{disturbanceLayer}{a \code{RasterLayer} object} 11 | 12 | \item{currentYear}{time of simulation} 13 | } 14 | \value{ 15 | Logical indicating whether to schedule a disturbance event 16 | } 17 | \description{ 18 | Test whether disturbance should be scheduled 19 | } 20 | \examples{ 21 | \dontrun{ 22 | doEvent <- scheduleDisturbance(sim$rstCurrentBurn, time(sim), disturbanceType = "Burn") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /man/speciesEcoregionLatestYear.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{speciesEcoregionLatestYear} 4 | \alias{speciesEcoregionLatestYear} 5 | \title{Pull out the values from \code{speciesEcoregion} table for current time} 6 | \usage{ 7 | speciesEcoregionLatestYear(speciesEcoregion, currentTime) 8 | } 9 | \arguments{ 10 | \item{speciesEcoregion}{A \code{data.table} with \code{species}-\code{ecoregion}-specific species trait values. 11 | Ecoregion refers to "ecolocation", a categorical variable grouping sites with similar biophysical 12 | characteristics. The table should have at least the following columns: \code{speciesCode} and 13 | \code{ecoregionGroup}, character representation of species and ecoregion groups respectively, 14 | \code{maxB} the maximum biomass for the species in a given 'ecoregion', \code{maxANPP} the maximum 15 | aboveground net primary productivity and \code{SEP} the species establishment probability. 16 | May contain columns \code{inflationFactor} (used to adjust \code{maxB}) and \code{mANPPproportion} 17 | (used to calculate \code{maxANPP}).} 18 | 19 | \item{currentTime}{The current simulation time e.g., \code{time(sim)}.} 20 | } 21 | \value{ 22 | The \code{speciesEcoregion} input object, but with data from only one year, the year 23 | that is less than or equal to the \code{currentTime} 24 | } 25 | \description{ 26 | Pull out the values from \code{speciesEcoregion} table for current time 27 | } 28 | -------------------------------------------------------------------------------- /man/speciesEcoregionStack.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ecoregions.R 3 | \name{speciesEcoregionStack} 4 | \alias{speciesEcoregionStack} 5 | \title{Create Stacks of the \code{speciesEcoregion} content} 6 | \usage{ 7 | speciesEcoregionStack( 8 | ecoregionMap, 9 | speciesEcoregion, 10 | columns = c("establishprob", "maxB", "maxANPP") 11 | ) 12 | } 13 | \arguments{ 14 | \item{ecoregionMap}{The \code{ecoregionMap}, a raster of all the unique ecoregion groupings, 15 | which group together pixels of similar biophysical characteristics.} 16 | 17 | \item{speciesEcoregion}{A \code{data.table} with \code{species}-\code{ecoregion}-specific species trait values. 18 | Ecoregion refers to "ecolocation", a categorical variable grouping sites with similar biophysical 19 | characteristics. The table should have at least the following columns: \code{speciesCode} and 20 | \code{ecoregionGroup}, character representation of species and ecoregion groups respectively, 21 | \code{maxB} the maximum biomass for the species in a given 'ecoregion', \code{maxANPP} the maximum 22 | aboveground net primary productivity and \code{SEP} the species establishment probability. 23 | May contain columns \code{inflationFactor} (used to adjust \code{maxB}) and \code{mANPPproportion} 24 | (used to calculate \code{maxANPP}).} 25 | 26 | \item{columns}{The columns to use in the \code{speciesEcoregion} data.table. 27 | Default is \code{c("establishprob", "maxB", "maxANPP")}} 28 | } 29 | \description{ 30 | This will output a list of \code{RasterStack} objects. Each \code{RasterStack} show raster maps 31 | of one of the columns listed in \code{columns} and each \code{RasterLayer} will be one species. 32 | } 33 | -------------------------------------------------------------------------------- /man/speciesPresent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/speciesPresentFromKNN.R 3 | \name{speciesPresentFromKNN} 4 | \alias{speciesPresentFromKNN} 5 | \alias{speciesInStudyArea} 6 | \title{Make a species factor raster} 7 | \usage{ 8 | speciesPresentFromKNN( 9 | year = 2011, 10 | dPath = asPath("."), 11 | res = 2000, 12 | minPctCover = 10 13 | ) 14 | 15 | speciesInStudyArea( 16 | studyArea, 17 | url = NULL, 18 | speciesPresentRas = NULL, 19 | dPath = getOption("reproducible.destinationPath") 20 | ) 21 | } 22 | \arguments{ 23 | \item{year}{Default (and only implemented) is 2011. This will download the 2011 KNN data layers} 24 | 25 | \item{dPath}{Passed to \code{destinationPath} in \code{preProcess}.} 26 | 27 | \item{res}{The resolution (one dimension, in m) for the resulting raster} 28 | 29 | \item{minPctCover}{An integer indicating what percent cover a species must have 30 | in a pixel to be considered present in that pixel.} 31 | 32 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 33 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 34 | 35 | \item{url}{A url to get a \code{speciesPresence} raster e.g., from \code{peciesPresentFromKNN}} 36 | 37 | \item{speciesPresentRas}{A factor raster where the character string is a string of 38 | species names, separated by 2 underscores, sorted alphabetically. Can be produced 39 | with \code{speciesPresentFromKNN}} 40 | } 41 | \value{ 42 | A \code{SpatRaster} object with 2 layers: \code{"speciesPresent"} is a factor, with 43 | a legend (i.e., it is numbers on a map, that correspond to a legend) and 44 | \code{"numberSpecies"} which represents the number of species in each pixel. 45 | 46 | A named list of length 2: \code{speciesRas} is a factor \code{RasterLayer} 47 | and \code{speciesList} is a character string containing the unique, sorted 48 | species on the \code{speciesRas}, for convenience. 49 | } 50 | \description{ 51 | This will download all KNN layers in (Boreal) Forest of Canada, and make 52 | a factor raster at resolution provided by \code{res} (larger is faster). 53 | 54 | \code{speciesInStudyArea} defaults to use a url of a dataset uploaded to Google Drive that is 55 | from Canadian Boreal Forests, but a different factor raster can be passed e.g., 56 | from \code{speciesPresentFromKNN}. 57 | } 58 | \examples{ 59 | \dontrun{ 60 | if (requireNamespace("googledrive", quietly = TRUE)) { 61 | # Make the dataset 62 | speciesPresent <- speciesPresentFromKNN(dPath = "~/data/KNN") 63 | 64 | # To upload this: 65 | speciesPresentRas <- terra::rast(speciesPresent)[[1]] 66 | fn <- "SpeciesPresentInCanadianForests.tif" 67 | writeRaster(speciesPresentRas, file = fn) 68 | zipFn <- gsub(".tif", ".zip", fn) 69 | zip(files = dir(pattern = fn), zipFn) 70 | out <- googledrive::drive_put(zipFn) 71 | driveID <- "1Oj78jJBeha5L6XDBBdWDAfimgNjYc9UD" 72 | 73 | # Get species list 74 | sa <- LandR::randomStudyArea(size = 1e11) 75 | species <- LandR::speciesInStudyArea(sa) 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /man/sppColors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{sppColors} 4 | \alias{sppColors} 5 | \title{Create species colour vector from a \code{sppEquiv} table} 6 | \usage{ 7 | sppColors(sppEquiv, sppEquivCol, newVals = NULL, palette) 8 | } 9 | \arguments{ 10 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 11 | See \code{data("sppEquivalencies_CA", "LandR")}. 12 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 13 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 14 | 15 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 16 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 17 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 18 | 19 | \item{newVals}{An optional character vector of extra names to use, e.g., "Mixed".} 20 | 21 | \item{palette}{An \pkg{RColorBrewer} palette, e.g., "Accent". 22 | Can get \pkg{RColorBrewer} palette names from \code{rownames(RColorBrewer::brewer.pal.info)}.} 23 | } 24 | \value{ 25 | A named vector of colour codes, where the names are the species names 26 | plus any extra names passed with \code{newVals}. 27 | } 28 | \description{ 29 | Create species colour vector from a \code{sppEquiv} table 30 | } 31 | -------------------------------------------------------------------------------- /man/sppEquivCheck.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/chooseName.R 3 | \name{sppEquivCheck} 4 | \alias{sppEquivCheck} 5 | \title{Check and expand \code{sppEquiv}} 6 | \usage{ 7 | sppEquivCheck(sppEquiv, ensureColumns = NULL, sppEquivCol = NULL) 8 | } 9 | \arguments{ 10 | \item{sppEquiv}{A character vector or \code{data.table} with named column(s). 11 | If this \code{data.table} does not have columns named \code{ensureColumns}, 12 | then it will attempt to merge this data.table with \code{sppEquivalencies_CA} 13 | to get \code{ensureColumns}.} 14 | 15 | \item{ensureColumns}{A character vector of column names that must be in \code{sppEquiv}. 16 | If these are not present, then the function will attempt to merge with 17 | \code{sppEquivalencies_CA}, so the column name(s) of \code{sppEquiv} must match 18 | column names in \code{sppEquivalencies_CA}.} 19 | 20 | \item{sppEquivCol}{Optional. Column in \code{sppEquivalencies_CA} to use for equivalent names 21 | when \code{sppEquiv} not provided (i.e., when \code{sppEquivalencies_CA} is used instead).} 22 | } 23 | \value{ 24 | A \code{data.table} with potentially all columns in \code{sppEquivalencies_CA}. 25 | } 26 | \description{ 27 | This will expand a \code{sppEquiv} object that is only a vector or only a one-column 28 | \code{data.table} into a many column \code{data.table}, if the columns that are present do not 29 | contain \code{ensureColumns}. 30 | } 31 | -------------------------------------------------------------------------------- /man/sppEquivalencies_CA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sppEquivalencies_CA.R 3 | \docType{data} 4 | \name{sppEquivalencies_CA} 5 | \alias{sppEquivalencies_CA} 6 | \title{Table of species name equivalencies for Canadian trees} 7 | \format{ 8 | A \code{data.frame} with 271 rows and 10 variables: 9 | \describe{ 10 | \item{LANDIS_test}{species names from LANDIS-II test parameter table} 11 | \item{LANDIS_traits}{species names from LANDIS-II traits parameter table} 12 | \item{LandR}{species names from LandR modules} 13 | \item{KNN}{species names from kNN datasets} 14 | \item{CASFRI}{species names from CASFRI database} 15 | \item{Latin_full}{accepted species latin names as in \url{http://theplantlist.org}} 16 | \item{EN_generic_short}{Short version of species' common names in English} 17 | \item{EN_generic_full}{Full species common names in English} 18 | \item{Leading}{Simple common English names used for leading species} 19 | \item{Notes}{additional notes and information} 20 | \item{Boreal}{Species present in the Boreal forests of Canada} 21 | \item{Type}{Whether the species is a deciduous or conifer species} 22 | \item{PSP}{species name from the module ianmseddy/PSP_Clean} 23 | \item{BC_Forestry}{the species code adopted by the Government of British Columbia} 24 | \item{FuelClass}{The fuel class used by the module PredictiveEcology/fireSense}#' 25 | } 26 | } 27 | \usage{ 28 | sppEquivalencies_CA 29 | } 30 | \description{ 31 | A table containing the different species names used across different sources (e.g., LANDIS-II 32 | test parameter files and trait tables, the LandR standard, kNN species biomass layers, etc.). 33 | Each column refers to a different source or species naming approach. 34 | Presently only containing Canadian native tree species, with name equivalencies coming from: 35 | \itemize{ 36 | \item LANDIS-II test parameter tables (column \code{LANDIStest_names}; 37 | source: \url{https://raw.githubusercontent.com/LANDIS-II-Foundation/Extensions-Succession/master/biomass-succession-archive/trunk/tests/v6.0-2.0/species.txt}); 38 | \item LANDIS-II Canada-wide trait table (column \code{LANDIStraits_names}; 39 | source: \url{https://raw.githubusercontent.com/dcyr/LANDIS-II_IA_generalUseFiles/master/speciesTraits.csv}); 40 | \item LandR family of SpaDES modules (column \code{LandR_names}; 41 | \item CFS kNN species biomass layers (column \code{KNN_names}; 42 | source: \url{http://tree.pfc.forestry.ca/kNN-Species.tar}); 43 | \item Canadian Common Attribute Schema for Forest Resource Inventories (column \code{CASFRI_names}; 44 | source \url{http://www.borealbirds.ca/files/CAS_Document_Final_Mar_2010_ALL_APPENDICES.pdf}). 45 | } 46 | } 47 | \details{ 48 | Remaining columns have been filled with some other useful ways to name species (e.g., for plotting). 49 | 50 | This table is currently used as the default equivalencies table in LandR SpaDES modules, 51 | but can also serve as a template to customize species names equivalencies by the user. 52 | } 53 | \keyword{datasets} 54 | -------------------------------------------------------------------------------- /man/sppHarmonize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sppHarmonize.R 3 | \name{sppHarmonize} 4 | \alias{sppHarmonize} 5 | \title{Harmonize the three components that bring species into \verb{Biomass_**} modules} 6 | \usage{ 7 | sppHarmonize( 8 | sppEquiv, 9 | sppNameVector, 10 | sppEquivCol, 11 | sppColorVect, 12 | vegLeadingProportion = 0, 13 | studyArea, 14 | dPath = getOption("reproducible.destinationPath") 15 | ) 16 | } 17 | \arguments{ 18 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 19 | See \code{data("sppEquivalencies_CA", "LandR")}. 20 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 21 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 22 | 23 | \item{sppNameVector}{A character vector of species to use. These species must all 24 | be from one naming convention, i.e., from one column in the \code{sppEquiv}.} 25 | 26 | \item{sppEquivCol}{A character string normally provided from the \code{P(sim)$sppEquivCol} 27 | (see manual). If \code{NA}, the default, then this will try to determine which 28 | column the \code{sppNameVector} used and use that. If \code{sppNameVector} is NULL, then 29 | it will default to \code{"Boreal"}.} 30 | 31 | \item{sppColorVect}{A named vector of colours to use for plotting. 32 | The names must conform with species name convention used 33 | (see \link{sppEquivalencies_CA} for possible naming 34 | conventions) and should also contain a colour for 'Mixed', 35 | when a mixed forest type is supported (see \code{vegLeadingProportion} 36 | parameter in \code{\link[=vegTypeGenerator]{vegTypeGenerator()}} for details on mixed 37 | forest types).} 38 | 39 | \item{vegLeadingProportion}{Numeric between 0-1, determining the relative biomass 40 | threshold a species needs to pass to be considered "leading".} 41 | 42 | \item{studyArea}{A \verb{SpatialPolygons*} object used as the principle study region, 43 | passed to \code{\link[reproducible:prepInputs]{reproducible::prepInputs()}}.} 44 | 45 | \item{dPath}{Passed to \code{speciesInStudyArea} (which then passes to \code{preProcess})} 46 | } 47 | \value{ 48 | Returns a named list with the same names as the arguments. These should 49 | likely be assigned to the \code{sim} object in the module following this function call. 50 | } 51 | \description{ 52 | This function will attempt to harmonize many potential issues/conflicts that 53 | may arise under different combinations of supplied objects to the three 54 | arguments. See manual for details. 55 | } 56 | \examples{ 57 | ## not run. usage example within module 58 | # sppOuts <- sppHarmonize(sim$sppEquiv, sim$sppNameVector, P(sim)$sppEquivCol) 59 | # sim$sppEquiv <- sppOuts$sppEquiv 60 | # sim$sppNameVector <- sppOuts$sppNameVector 61 | # P(sim)$sppEquivCol <- sppOuts$sppEquivCol 62 | 63 | } 64 | -------------------------------------------------------------------------------- /man/standAgeMapGenerator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{standAgeMapGenerator} 4 | \alias{standAgeMapGenerator} 5 | \title{Produce stand age map based on \code{cohortData}} 6 | \usage{ 7 | standAgeMapGenerator( 8 | cohortData, 9 | pixelGroupMap, 10 | weight = "biomass", 11 | doAssertion = getOption("LandR.assertions", FALSE) 12 | ) 13 | } 14 | \arguments{ 15 | \item{cohortData}{A \code{data.table} with columns: \code{pixelGroup}, \code{ecoregionGroup}, 16 | \code{speciesCode}, and optionally \code{age}, \code{B}, \code{mortality}, \code{aNPPAct}, and \code{sumB}.} 17 | 18 | \item{pixelGroupMap}{A \code{RasterLayer} with pixel values equal to a pixel group 19 | number that corresponds exactly to \code{pixelGroup} column in \code{cohortData}.} 20 | 21 | \item{weight}{variable by which to weight \code{cohortData} ages. one of \code{"biomass"} or \code{NA}. 22 | \code{NA} means use max unweighted age.} 23 | 24 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 25 | ensure the function is running correctly. 26 | Default: \code{getOption("LandR.assertions", TRUE)}.} 27 | } 28 | \value{ 29 | raster of the same type as \code{pixelGroupMap}. 30 | } 31 | \description{ 32 | Produce stand age map based on \code{cohortData} 33 | } 34 | -------------------------------------------------------------------------------- /man/statsModel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{statsModel} 4 | \alias{statsModel} 5 | \title{The generic statistical model to run (\code{lmer} or \code{glmer})} 6 | \usage{ 7 | statsModel(modelFn, uniqueEcoregionGroups, sumResponse, .specialData) 8 | } 9 | \arguments{ 10 | \item{modelFn}{A quoted expression of type \code{package::model(Y ~ X, ...)}, omitting 11 | the \code{data} argument. E.g. \code{lme4::glmer(Y ~ X + (X|G), family = poisson)}} 12 | 13 | \item{uniqueEcoregionGroups}{Unique values of \code{ecoregionGroups}. 14 | This is the basis for the statistics, and can be used to optimize caching, 15 | e.g. ignore \code{.specialData} in \code{.omitArgs}.} 16 | 17 | \item{sumResponse}{a sum of all the response variable values 18 | Also to be used to optimize caching, e.g. ignore \code{.specialData} 19 | in \code{.omitArgs}.} 20 | 21 | \item{.specialData}{The custom dataset required for the model.} 22 | } 23 | \description{ 24 | This does a few things including R squared, gets the fitted values. 25 | It appears that running the models "as is" without this wrapper does not work with \code{Cache}. 26 | The return of the model in a list solves this problem. 27 | For Caching, the \code{.specialData} should be "omitted" via \code{omitArgs}, and 28 | \code{uniqueEcoregionGroups} should not be omitted. 29 | } 30 | -------------------------------------------------------------------------------- /man/subsetDT.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{subsetDT} 4 | \alias{subsetDT} 5 | \title{Subset a \code{data.table} with random subsampling within \code{by} groups} 6 | \usage{ 7 | subsetDT(DT, by, doSubset = TRUE, indices = FALSE) 8 | } 9 | \arguments{ 10 | \item{DT}{A \code{data.table}} 11 | 12 | \item{by}{Character vector of column names to use for groups} 13 | 14 | \item{doSubset}{Logical or numeric indicating the number of subsamples to use} 15 | 16 | \item{indices}{Logical. If \code{TRUE}, this will return vector of row indices only. Defaults 17 | to \code{FALSE}, i.e., return the subsampled \code{data.table}} 18 | } 19 | \description{ 20 | Subset a \code{data.table} with random subsampling within \code{by} groups 21 | } 22 | \examples{ 23 | library(data.table) 24 | dt <- data.table(Lett = sample(LETTERS, replace = TRUE, size = 1000), Nums = 1:100) 25 | dt1 <- subsetDT(dt, by = "Lett", doSubset = 3) 26 | } 27 | -------------------------------------------------------------------------------- /man/sumRastersBySpecies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{sumRastersBySpecies} 4 | \alias{sumRastersBySpecies} 5 | \title{Function to sum rasters of species layers} 6 | \usage{ 7 | sumRastersBySpecies(speciesLayers, layersToSum, filenameToSave, newLayerName) 8 | } 9 | \arguments{ 10 | \item{speciesLayers}{A \code{RasterStack} or \code{RasterLayer} that 11 | should contain species cover data in the study area} 12 | 13 | \item{layersToSum}{names/indices of layers to be summed - optional} 14 | 15 | \item{filenameToSave}{file path to save output raster} 16 | 17 | \item{newLayerName}{name of the output raster layer} 18 | } 19 | \description{ 20 | Function to sum rasters of species layers 21 | } 22 | -------------------------------------------------------------------------------- /man/uniqueDefinitions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \docType{data} 4 | \name{uniqueCohortDefinition} 5 | \alias{uniqueCohortDefinition} 6 | \alias{uniqueSpeciesEcoregionDefinition} 7 | \title{The columns in a \code{cohortData} that define "unique"} 8 | \format{ 9 | An object of class \code{character} of length 4. 10 | 11 | An object of class \code{character} of length 2. 12 | } 13 | \usage{ 14 | uniqueCohortDefinition 15 | 16 | uniqueSpeciesEcoregionDefinition 17 | } 18 | \description{ 19 | If two pixels have identical values in all of these columns, they are the same \code{pixelGroup}. 20 | } 21 | \keyword{datasets} 22 | -------------------------------------------------------------------------------- /man/updateSpeciesTable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/speciesTable.R 3 | \name{updateSpeciesTable} 4 | \alias{updateSpeciesTable} 5 | \title{Customize species trait table values} 6 | \usage{ 7 | updateSpeciesTable(speciesTable, params) 8 | } 9 | \arguments{ 10 | \item{speciesTable}{A species traits table, with \strong{at least} the following columns: 11 | \itemize{ 12 | \item \code{speciesCode} an character representation of species; 13 | \item \code{Area} a character of geographical area within a species range for which trait values are relevant; 14 | \item \code{longevity} species longevity in years, \code{sexualmature} age in years at sexual maturity; 15 | \item \code{shadetolerance} numeric value between 1-5 of relative shade tolerance (with respect to other species); 16 | \item \code{seeddistance_eff} the "effective" seed dispersal distance; 17 | \item \code{seeddistance_max} a numeric with the maximum seed dispersal distance; 18 | \item \code{mortalityshape} and \code{growthcurve}: growth curve shape parameters. 19 | Other columns (e.g. fire-related traits) can also be included depending on LandR modules in use. 20 | Please see the LANDIS-II Biomass Succession Extension v3.2.1 manual (Scheller and Miranda 2015) 21 | for further detail. 22 | }} 23 | 24 | \item{params}{A named list (of parameters) of named lists (by species), with species 25 | traits overrides (e.g., \code{list(seeddistance_eff = list(Abie_sp = 25))}).} 26 | } 27 | \description{ 28 | Customize species trait table values 29 | } 30 | \author{ 31 | Alex Chubaty and Ceres Barros 32 | } 33 | -------------------------------------------------------------------------------- /man/vegTypeGenerator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cohorts.R 3 | \name{vegTypeGenerator} 4 | \alias{vegTypeGenerator} 5 | \title{Generate and add vegetation type column to \code{cohortData}} 6 | \usage{ 7 | vegTypeGenerator( 8 | x, 9 | vegLeadingProportion = 0.8, 10 | mixedType = 2, 11 | sppEquiv = NULL, 12 | sppEquivCol, 13 | pixelGroupColName = "pixelGroup", 14 | doAssertion = getOption("LandR.assertions", TRUE), 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{x}{A \code{cohortData} object} 20 | 21 | \item{vegLeadingProportion}{Numeric between 0-1, determining the relative biomass 22 | threshold a species needs to pass to be considered "leading".} 23 | 24 | \item{mixedType}{An integer defining whether mixed stands are: 25 | not differentiated (0), any kind of species admixture (1), 26 | or deciduous mixed with conifer (2; default).} 27 | 28 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 29 | See \code{data("sppEquivalencies_CA", "LandR")}. 30 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 31 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 32 | 33 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 34 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 35 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 36 | 37 | \item{pixelGroupColName}{Name of the column in \code{pixelGroup} to use.} 38 | 39 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 40 | ensure the function is running correctly. 41 | Default: \code{getOption("LandR.assertions", TRUE)}.} 42 | 43 | \item{...}{Additional arguments.} 44 | } 45 | \value{ 46 | \code{x} with a new column, 'leading', coding the vegetation type 47 | of each group defined by \code{pixelGroupColName} 48 | } 49 | \description{ 50 | This function is a simplification of \code{vegTypeMapGenerator} 51 | and instead of generating a map, it adds the vegetation type column 52 | to the \code{cohortData} table. 53 | } 54 | \examples{ 55 | library(data.table) 56 | x <- data.table( 57 | pixelGroup = rep(1:2, each = 2), B = c(100, 200, 20, 400), 58 | speciesCode = rep(c("Pice_Gla", "Popu_Tre"), 2) 59 | ) 60 | vegTypeGenerator(x) 61 | } 62 | \author{ 63 | Eliot McIntire, Ceres Barros, Alex Chubaty 64 | } 65 | -------------------------------------------------------------------------------- /man/vegTypeMapGenerator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/maps.R 3 | \name{vegTypeMapGenerator} 4 | \alias{vegTypeMapGenerator} 5 | \alias{vegTypeMapGenerator.default} 6 | \alias{vegTypeMapGenerator.data.table} 7 | \title{Generate vegetation type map} 8 | \usage{ 9 | vegTypeMapGenerator(x, ...) 10 | 11 | \method{vegTypeMapGenerator}{default}(x, ..., doAssertion = getOption("LandR.assertions", FALSE)) 12 | 13 | \method{vegTypeMapGenerator}{data.table}( 14 | x, 15 | pixelGroupMap, 16 | vegLeadingProportion = 0.8, 17 | mixedType = 2, 18 | sppEquiv = NULL, 19 | sppEquivCol, 20 | colors, 21 | pixelGroupColName = "pixelGroup", 22 | doAssertion = getOption("LandR.assertions", TRUE), 23 | ... 24 | ) 25 | } 26 | \arguments{ 27 | \item{x}{Either a \code{cohortData} object or a \code{speciesCover} \code{RasterStack}/\code{SpatRaster}} 28 | 29 | \item{...}{Additional arguments.} 30 | 31 | \item{doAssertion}{A logical indicating whether some internal tests should be run to 32 | ensure the function is running correctly. 33 | Default: \code{getOption("LandR.assertions", TRUE)}.} 34 | 35 | \item{pixelGroupMap}{A \code{RasterLayer} with pixel values equal to a pixel group 36 | number that corresponds exactly to \code{pixelGroup} column in \code{cohortData}.} 37 | 38 | \item{vegLeadingProportion}{Numeric between 0-1, determining the relative biomass 39 | threshold a species needs to pass to be considered "leading".} 40 | 41 | \item{mixedType}{An integer defining whether mixed stands are: 42 | not differentiated (0), any kind of species admixture (1), 43 | or deciduous mixed with conifer (2; default).} 44 | 45 | \item{sppEquiv}{table with species name equivalencies between the kNN and final naming formats. 46 | See \code{data("sppEquivalencies_CA", "LandR")}. 47 | For functions that have \code{mixedType}, this only necessary if \code{mixedType == 2}. 48 | If not provided and \code{mixedType == 2}, will attempt to use \code{data("sppEquivalencies_CA", "LandR")}.} 49 | 50 | \item{sppEquivCol}{the column name to use from \code{sppEquiv}. 51 | For functions that have \code{mixedType}, only necessary if \code{mixedType == 2}. 52 | If not provided and \code{mixedType == 2}, will attempt to use "Boreal".} 53 | 54 | \item{colors}{A named vector of colour codes. The names MUST match the names of species 55 | in \code{cohortData$speciesCode}, plus an optional "Mixed" colour.} 56 | 57 | \item{pixelGroupColName}{Name of the column in \code{pixelGroup} to use.} 58 | } 59 | \description{ 60 | Generate vegetation type map 61 | } 62 | \examples{ 63 | library(data.table) 64 | library(terra) 65 | x <- data.table(pixelGroup = rep(1:2, each = 2), B = c(100, 200, 20, 400), 66 | speciesCode = rep(c("Pice_Gla", "Popu_Tre"), 2)) 67 | pixelGroupMap <- rast(ext(0,3, 0, 3), res = 1) 68 | pixelGroupMap[] <- sample(1:2, size = 9, replace = TRUE) 69 | vtm <- vegTypeMapGenerator(x, pixelGroupMap = pixelGroupMap) 70 | 71 | } 72 | \author{ 73 | Eliot McIntire, Ceres Barros, Alex Chubaty 74 | } 75 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | withr::local_options(list( 2 | warnPartialMatchArgs = TRUE, 3 | warnPartialMatchAttr = TRUE, 4 | warnPartialMatchDollar = TRUE 5 | )) 6 | 7 | library(testthat) 8 | library(LandR) 9 | 10 | test_check("LandR") 11 | -------------------------------------------------------------------------------- /tests/testthat/test-speciesTable.R: -------------------------------------------------------------------------------- 1 | test_that("speciesTable has correct column types", { 2 | skip_if_offline() 3 | 4 | test_dir <- file.path(tempdir(), "test_speciesTable") 5 | dir.create(test_dir, recursive = TRUE) 6 | on.exit({ 7 | reproducible::clearCache(ask = FALSE) 8 | unlink(test_dir, recursive = TRUE) 9 | }, add = TRUE) 10 | 11 | expect_no_warning({ 12 | sTraw <- getSpeciesTable(dPath = test_dir) 13 | }) 14 | expect_no_error(assertSpeciesTableRaw(sTraw)) 15 | 16 | sT <- data.table::copy(sTraw) 17 | expect_no_warning({ 18 | sT <- prepSpeciesTable(sT) 19 | }) 20 | expect_no_error(assertSpeciesTable(sT)) 21 | }) 22 | --------------------------------------------------------------------------------