Skip to content

Commit

Permalink
fix prepInputsFireYear() rasterization problems
Browse files Browse the repository at this point in the history
  • Loading branch information
achubaty committed Sep 27, 2024
1 parent 3908d3b commit 5273950
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ URL:
https://landr.predictiveecology.org,
https://github.com/PredictiveEcology/LandR
Date: 2024-09-27
Version: 1.1.5.9023
Version: 1.1.5.9024
Authors@R: c(
person("Eliot J B", "McIntire", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")),
Expand Down
6 changes: 5 additions & 1 deletion R/prepInputObjects.R
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,12 @@ prepInputsFireYear <- function(..., rasterToMatch, fireField = "YEAR", earliestY
d[[fireField]] <- as.numeric(as.factor(d[[fireField]]))
}
if (is(rasterToMatch, "SpatRaster")) {
if (!is(d, "SpatVector")) {
d <- vect(d)
}
fireRas <- terra::rasterize(d, rasterToMatch, field = fireField)
fireRas[!is.na(terra::values(fireRas)) & terra::values(fireRas) < earliestYear] <- NA
fireRas[!is.na(terra::values(fireRas, mat = FALSE)) &
terra::values(fireRas, mat = FALSE) < earliestYear] <- NA
} else {
.requireNamespace("fasterize", stopOnFALSE = TRUE)
fireRas <- fasterize::fasterize(d, raster = rasterToMatch, field = fireField)
Expand Down

0 comments on commit 5273950

Please sign in to comment.