Skip to contents

fire_exp_extract() extracts the underlying exposure value for each feature in the values layer. Values can be provided as either points or polygons, and must be singlepart features (i.e. the attribute table has one row per value). If the values are polygon features both the maximum and mean exposure is computed.

Usage

fire_exp_extract(exposure, values)

Arguments

exposure

SpatRaster (e.g. from fire_exp())

values

Spatvector of points or polygons

Value

a SpatVector object with new attributes

Examples

# read example hazard data ----------------------------------
filepath <- "extdata/hazard.tif"
haz <- terra::rast(system.file(filepath, package = "fireexposuR"))
# read example AOI
filepath <- "extdata/builtsimpleexamplegeom.csv"
g <- read.csv(system.file(filepath, package = "fireexposuR"))
v <- terra::vect(as.matrix(g), "polygons", crs = haz)
# generate random points
pts <- terra::spatSample(v, 200)
# ----------------------------------------------------------

exp <- fire_exp(haz)

# extract exposure to point values
fire_exp_extract(exp, pts)
#>  class       : SpatVector 
#>  geometry    : points 
#>  dimensions  : 200, 1  (geometries, attributes)
#>  extent      : 497972.4, 501772.4, 4998467, 5001378  (xmin, xmax, ymin, ymax)
#>  coord. ref. : WGS 84 / UTM zone 8N (EPSG:32608) 
#>  names       : exposure
#>  type        :    <num>
#>  values      :    0.375
#>                       0
#>                       0