Skip to contents

Calculates Phytophthora cinnamomi's ensemble risk from raw data

Usage

phytorisk_ensemble_raw(
  aoi,
  poi,
  dem,
  treecover,
  weights = "equal",
  th = 100,
  buffer = 50,
  include_zoospread = FALSE,
  append_mec = FALSE,
  ...,
  quiet = FALSE
)

Arguments

aoi

A sf polygon representing the area of interest. Used to mask the tree cover

poi

A single-point sf object denoting the point of interest to run the simulations

dem

A single-band SpatRaster with a digital elevation model

treecover

A single-band SpatRaster where 1 represents host trees, and 0 represents background area

weights

weights of the ensemble model. The default uses the same weights for each model. The argument accepts a numeric vector with the corresponding weights. See phytorisk_ensemble

th

Threshold of flow accumulation to delineate streams

buffer

A buffer in meters to extend the spread in every direction

include_zoospread

logical. Whether to include the optional module of mec_zoospread

append_mec

Logical. Whether to append to the results of each individual module to the output SpatRaster

...

arguments passed to mec_zoospread

quiet

A logical value. If TRUE, suppresses any informational messages. Defaults to FALSE.

Value

A SpatRaster

Details

This function is a one-step convenience wrapper around the four dispersal mechanism functions and phytorisk_ensemble. It runs the following pipeline internally:

  1. mec_soilwater — models Pc spread through soil water pathways using flow direction and accumulation derived from dem. The th argument controls the flow-accumulation threshold used to delineate streams.

  2. mec_rootcontact — models root-to-root transmission across a 3×3 spatial window over the treecover raster within aoi.

  3. mec_surfacewater — models surface water spread using the Topographic Wetness Index derived from dem. It receives the output of mec_soilwater directly; buffer extends the detected water bodies before computing risk.

  4. mec_zoospread (optional) — simulates animal-mediated dispersal trajectories within aoi. Only executed when include_zoospread = TRUE; additional arguments via ... are forwarded to this function.

The four mechanism outputs are then combined by phytorisk_ensemble into a single ensemble risk surface. See phytorisk_ensemble for details on how weights are applied.

When append_mec = TRUE the individual mechanism rasters are concatenated with the ensemble layer in the returned SpatRaster, allowing inspection of each component alongside the final risk surface.

Examples

# \donttest{
## load packages
library(phytorisk)
library(sf)
library(terra)

## load data
poi_sf <- st_read(
  system.file("spatial/poi.geojson", package = "phytorisk"),
  quiet = TRUE
)
dem_sr <- rast(system.file("spatial/dem_light.tiff", package = "phytorisk"))
trees_sr <- rast(system.file("spatial/trees_light.tiff", package = "phytorisk"))
aoi_sf <- st_read(
  system.file("spatial/tejera.geojson", package = "phytorisk"),
  quiet = TRUE
)

## calculate ensemble risk, returning individual mechanisms
risk_equal_sr <- phytorisk_ensemble_raw(
  aoi = aoi_sf,
  poi = poi_sf,
  dem = dem_sr,
  treecover = trees_sr,
  append_mec = TRUE
)
#> 
#> ── Mec Ii - Spread in soil water ───────────────────────────────────────────────
#>  Filling DEM...
#>  DEM filled [17ms]
#> 
#>  Filling basins...
#>  Basins filled [40ms]
#> 
#>  Removing depressions...
#>  Depressions removed [29ms]
#> 
#>  Filling depressions...
#>  Depressions filled [30ms]
#> 
#>  Getting flow directions...
#>  Flow directions [30ms]
#> 
#>  Calculating flow accumulation...
#>  Flow accumulation calculated [29ms]
#> 
#>  Delineating streams...
#>  Streams delineated [23ms]
#> 
#>  Determining the wet front
#>  Wet front determined [700ms]
#> 
#> 
#> ── Mec Iii - Root-to-root contact ──────────────────────────────────────────────
#>  Preparing tree data...
#>  Tree data prepared [63ms]
#> 
#>  Finding root-to-root contact...
#>  Finished [13.4s]
#> 
#> 
#> ── Mec II - Spread in surface water ────────────────────────────────────────────
#>  Calculating natural drainage network...
#>  Natural drainage network calculated [39ms]
#> 
#>  Identifying surface water close to foci...
#>  Surface water close to foci identified [54ms]
#> 
#>  Finding connected pixels...
#>  Finished [821ms]
#> 

## visualize results
plot(risk_equal_sr)

# }