diff --git a/R/SAPA.R b/R/SAPA.R index 755eed8..760900b 100644 --- a/R/SAPA.R +++ b/R/SAPA.R @@ -119,7 +119,7 @@ SAPA<- function(r=NULL, w = 1, slope_correction=TRUE, na.rm=FALSE, include_scale } # Sum up surface area in focal window (or scale mean to number of cells) if(is.null(slope_layer) & slope_correction){ - if (all(w==1)){ + if (all(w==1) & (!na.rm)){ slope_layer<- terra::terrain(r, v="slope", unit="radians", neighbors=8, wopt=wopt) } else{ slope_layer<- SlpAsp(r, w=w+2, unit="radians", method="queen", metrics= "slope", na.rm=na.rm, include_scale=FALSE, wopt=wopt) diff --git a/README.md b/README.md index 0ac1ec1..87176a8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ README ================ Alexander Ilich -September 12, 2023 +December 30, 2023 # MultiscaleDTM @@ -279,7 +279,7 @@ vrm<- VRM(r, w=c(5,5), na.rm = TRUE) ![](man/figures/README-VRM-1.png) ``` r -sapa<- SAPA(r, w=c(5,5), slope_correction = TRUE) +sapa<- SAPA(r, w=c(5,5), slope_correction = TRUE, na.rm=TRUE) ``` ![](man/figures/README-SAPA-1.png) diff --git a/man/fragments/README_Frag.Rmd b/man/fragments/README_Frag.Rmd index d75dc1b..4337f27 100644 --- a/man/fragments/README_Frag.Rmd +++ b/man/fragments/README_Frag.Rmd @@ -248,7 +248,7 @@ tm_shape(vrm, raster.downsample = FALSE)+ ``` ```{r} -sapa<- SAPA(r, w=c(5,5), slope_correction = TRUE) +sapa<- SAPA(r, w=c(5,5), slope_correction = TRUE, na.rm=TRUE) ``` ```{r SAPA, echo=FALSE}