-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new function for landscape burn summary
- Loading branch information
Showing
4 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Type: Package | |
Title: Utilities for Working With the 'fireSense' Group of 'SpaDES' Modules | ||
Description: Utilities for working with the 'fireSense' group of 'SpaDES' modules. | ||
Date: 2024-12-20 | ||
Version: 0.0.5.9078 | ||
Version: 0.0.5.9079 | ||
Authors@R: c( | ||
person("Jean", "Marchal", email = "[email protected]", | ||
role = c("aut")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#' Calculate proportional burn of landcover and tree species | ||
#' | ||
#' @template pixelGroupMap | ||
#' @template cohortData | ||
#' @param rstLCC a landcover map | ||
#' @param nonflammableLCC nonflammable landcover in rstLCC | ||
#' @param fires a single sf or SpatVector object of fire polygons containing a YEAR coumn | ||
#' @param yearRange the range of years represented by this landscape | ||
#' | ||
#' @return a data.table with cell, biomass, tree species or lcc for non-forest, and year of fire | ||
#' @export | ||
#' | ||
#' @examples | ||
#' fuelclassPrep(sim$pixelGroupMap2011, sim$cohortData2011, sim$rstLCC2011, | ||
#' nonflammableLCC = P(sim)$nonflammableLCC< yearRange = c(2012, 2020)) | ||
fuelClassPrep <- function(pixelGroupMap, cohortData, rstLCC, nonflammableLCC, fires, yearRange) { | ||
# Filter fires by year range | ||
firesSubset <- fires[fires$YEAR >= yearRange[1] & fires$YEAR <= yearRange[2], ] |> | ||
rasterize(pixelGroupMap, field = "YEAR", fun = "min") |> | ||
as.data.frame(cells = TRUE) |> as.data.table() | ||
|
||
# Add pixels to cohort data | ||
speciesData <- addPixels2CohortData(cohortData = cohortData, pixelGroupMap) | ||
|
||
# Prepare landscape data excluding non-flammable land cover classes | ||
landscapeData <- as.data.table(as.data.frame(rstLCC, cells = TRUE)) |> | ||
setnames(c("cell", "lcc")) | ||
landscapeData <- landscapeData[!lcc %in% nonflammableLCC] | ||
|
||
# Merge species data with landscape data | ||
landscapeData <- speciesData[landscapeData, on = c("pixelIndex" = "cell")] | ||
|
||
# Merge fires data with landscape data | ||
landscapeData <- firesSubset[landscapeData, on = c("cell" = "pixelIndex")] | ||
|
||
return(landscapeData) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.