Skip to content

Commit

Permalink
Slight SAPA Fix
Browse files Browse the repository at this point in the history
- Only call terrain if w=1 and na.rm=FALSE
  • Loading branch information
ailich committed Dec 30, 2023
1 parent 6d340f3 commit e45ae09
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/SAPA.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
README
================
Alexander Ilich
September 12, 2023
December 30, 2023

# MultiscaleDTM

Expand Down Expand Up @@ -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)<!-- -->
Expand Down
2 changes: 1 addition & 1 deletion man/fragments/README_Frag.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit e45ae09

Please sign in to comment.