From df138b019aa17475a8d08a8b22d761e60521403f Mon Sep 17 00:00:00 2001 From: Jean-Matthieu Monnet <jean-matthieu.monnet@inrae.fr> Date: Fri, 10 Feb 2023 13:57:00 +0100 Subject: [PATCH] Avoid terra::merge bug in versions 1.7.3 and 1.7.6 --- R/area-based.3.mapping.and.inference.Rmd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/area-based.3.mapping.and.inference.Rmd b/R/area-based.3.mapping.and.inference.Rmd index 517f619..0e0a310 100755 --- a/R/area-based.3.mapping.and.inference.Rmd +++ b/R/area-based.3.mapping.and.inference.Rmd @@ -447,7 +447,11 @@ model_public <- list(model = model_aba_stratified_mixed$model$public, stats = mo # produce corresponding map prediction_map_public <- lidaRtRee::aba_predict(model_public, metrics_map) # TEMPORARY fix to NA values in terra::merge (call by lidaRtRee::aba_predict) -prediction_map_mixed <- terra::mosaic(prediction_map_public, prediction_map_private, fun = max) +if (packageVersion("terra")<"1.7.3" | packageVersion("terra")>="1.7.8") +{ + warning("Merging with terra::mosaic because terra::merge in 1.7.3 and 1.7.6 does not handle NA values") + prediction_map_mixed <- terra::mosaic(prediction_map_public, prediction_map_private, fun = max) +} ``` ```{r plotmapForestStratified, include=TRUE, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 12, fig.height = 6} -- GitLab