Skip to content

Commit 24a7ce0

Browse files
Add overwrite param to makeFireSenseLCC
assuming this was planned prior because the param had already been added to function call in fireSense_dataPrepPredict
1 parent cb0379a commit 24a7ce0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

R/makeFireSenseLCC.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#' @param destinationPath Character string. Directory path where source NTEMS data
3636
#' will be downloaded/loaded (via `prepInputs_NTEMS_LCC_FAO`) and where the
3737
#' output raster will be written if `writeTo` is specified.
38+
#' @param overwrite Logical. Overwrite NTEMS FAO and flammable pixels rasters.
3839
#'
3940
#' @return A list of two `SpatRaster` objects:
4041
#' 1) the processed land cover classification at the resolution, extent,
@@ -76,19 +77,19 @@
7677
makeFireSenseLCC <- function(neededYear, to, maskTo = NULL, # to, maskTo = NULL,
7778
nonflammableLCC = c(20, 31, 32, 33),
7879
flammabilityThreshold = 0.1, writeTo = NULL,
79-
destinationPath) {
80+
overwrite = TRUE, destinationPath) {
8081
# 1. Retrieve and prepare base NTEMS LCC data for the specified year
8182
# - Crops to the extent of to
8283
# - Masks to the maskTo polygon(s)
8384
message("Preparing base NTEMS LCC data...")
84-
85+
browser()
8586
maskToArg <- if (is.null(maskTo)) to else maskTo
8687

8788

8889
# if (exists("aaaa", envir = .GlobalEnv)) browser()
8990
rstLCC <- prepInputs_NTEMS_LCC_FAO(year = neededYear,
9091
disturbedCode = 240, # Optional: specify disturbed code if needed
91-
overwrite = TRUE, # Consider parameterizing overwrite?
92+
overwrite = overwrite,
9293
destinationPath = destinationPath,
9394
cropTo = to,
9495
maskTo = maskToArg)
@@ -134,7 +135,7 @@ makeFireSenseLCC <- function(neededYear, to, maskTo = NULL, # to, maskTo = NULL,
134135
propFlamPath <- .suffix(outPath, "_propFlam")
135136
message("Writing output raster to: ", outPath)
136137
# Ensure data type supports 0 if original LCC didn't (though usually integer, so fine)
137-
allFlam <- terra::writeRaster(allFlam, filename = outPath, overwrite = TRUE)
138+
allFlam <- terra::writeRaster(allFlam, filename = outPath, overwrite = overwrite)
138139
flammableProp <- writeRaster(flammableProp, filename = propFlamPath, overwrite = TRUE)
139140
}
140141

man/makeFireSenseLCC.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)