From c4428e970845096c8b9d848280a55316a5e98958 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Wed, 5 Jun 2024 11:27:51 -0600 Subject: [PATCH] properly fix for prepInputsFireRegimePolys when url supplied by user --- DESCRIPTION | 4 ++-- R/utils_fireRegimePolys.R | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c3aea69..df5d405 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,8 +8,8 @@ Description: The original fire model is described by Cumming et al. (1998), URL: https://scfmutils.predictiveecology.org, https://github.com/PredictiveEcology/scfmutils, https://predictiveecology.github.io/scfmutils/ -Date: 2024-05-09 -Version: 0.0.13.9001 +Date: 2024-06-05 +Version: 0.0.13.9002 Authors@R: c( person("Steve", "Cumming", email = "Steve.Cumming@sbf.ulaval.ca", role = c("aut")), diff --git a/R/utils_fireRegimePolys.R b/R/utils_fireRegimePolys.R index 5f98283..0dbe6b8 100644 --- a/R/utils_fireRegimePolys.R +++ b/R/utils_fireRegimePolys.R @@ -123,6 +123,20 @@ prepInputsFireRegimePolys <- function(url = NULL, destinationPath = tempdir(), tmp <- sf::st_transform(tmp, sf::st_crs(studyArea)) } } + } else { + tmp <- prepInputs(url = url, + destinationPath = destinationPath, + studyArea = studyArea, + rasterToMatch = rasterToMatch, + fun = "sf::st_read", + overwrite = TRUE) ## TODO: doesn't reproject -- fix upstream? + + ## workaround issues with prepInputs() not reprojecting: + if (!is.null(rasterToMatch)) { + tmp <- sf::st_transform(tmp, raster::crs(rasterToMatch)) + } else if (is.null(rasterToMatch) && !is.null(studyArea)) { + tmp <- sf::st_transform(tmp, sf::st_crs(studyArea)) + } } if (grepl("^ECO", type)) {