This indicator allows the extraction of zonal statistics for resource layers
previously downloaded from SoilGrids, thus in total supporting the calculation
of zonal statistics for 10 different soil properties at 6 different depths for
a total of 4 different model outputs (stat). Zonal statistics will be calculated
for all SoilGrid layers that have been previously made available vie get_resources()
.
The required resource for this indicator is:
Format
A tibble with a column for the SoilGrid layer, the depth and the model
output statistic as well as additional columns for all zonal statistics
specified via stats_soil
Details
The following arguments can be set:
- stats_soil
Function to be applied to compute statistics for polygons either single or multiple inputs as character. Supported statistics are: "mean", "median", "sd", "min", "max", "sum" "var".
- engine
The preferred processing functions from either one of "zonal", "extract" or "exactextract" as character.
Examples
# \dontshow{
mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data"))
# }
# \dontrun{
library(sf)
library(mapme.biodiversity)
outdir <- file.path(tempdir(), "mapme-data")
dir.create(outdir, showWarnings = FALSE)
aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg",
package = "mapme.biodiversity"
) %>%
read_sf() %>%
init_portfolio(
years = 2022,
outdir = outdir,
tmpdir = tempdir(),
add_resources = FALSE,
verbose = FALSE
) %>%
get_resources("soilgrids",
layers = c("clay", "silt"), depths = c("0-5cm", "5-15cm"), stats = "mean"
) %>%
calc_indicators("soilproperties", stats_soil = c("mean", "median"), engine = "extract") %>%
tidyr::unnest(soilproperties)
aoi
#> Simple feature collection with 4 features and 10 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -71.80933 ymin: 18.57668 xmax: -71.33201 ymax: 18.69931
#> Geodetic CRS: WGS 84
#> # A tibble: 4 × 11
#> WDPAID NAME DESIG_ENG ISO3 assetid layer depth stat mean median
#> <dbl> <chr> <chr> <chr> <int> <chr> <chr> <chr> <dbl> <dbl>
#> 1 478140 Sierra de Neiba National … DOM 1 clay 0-5cm mean 35.0 34.8
#> 2 478140 Sierra de Neiba National … DOM 1 clay 5-15… mean 35.4 35.3
#> 3 478140 Sierra de Neiba National … DOM 1 silt 0-5cm mean 33.8 33.7
#> 4 478140 Sierra de Neiba National … DOM 1 silt 5-15… mean 33.9 33.8
#> # ℹ 1 more variable: geom <POLYGON [°]>
# }