| Title: | Least-Cost Pedestrian Evacuation Modeling |
|---|---|
| Description: | Tools for road-constrained, least-cost pedestrian evacuation modeling. The package provides reusable functions for preparing hazard zones, generating road-based evacuation origin points, identifying escape/safety points, creating slope-based conductance surfaces, calculating least-cost distance to safety, and converting distance outputs into evacuation-time polygons. It is designed to support workflows like tsunami evacuation modeling while remaining adaptable to other regions and hazards. Tsunami-specific helpers support separate land-only hazard zones, water-combined escape zones, road-aware escape boundaries, and study-area inset cropping for quality assurance and quality control. Methods build on Cordero et al. (2025) <doi:10.1007/s44367-025-00018-y>, Lewis (2021) <doi:10.1007/s10816-021-09522-w>, and Joseph Lewis's 'leastcostpath' package (2023) <https://CRAN.R-project.org/package=leastcostpath>. |
| Authors: | Elvin Cordero [aut, cre] |
| Maintainer: | Elvin Cordero <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-06-02 10:30:20 UTC |
| Source: | https://github.com/el-cordero/evacpath |
evacpath provides tools for modeling pedestrian evacuation distance and
travel time from hazard zones to safety areas using road-constrained least-cost
path analysis.
The package is organized as a set of modular functions. Typical workflows use
prepare_tsunami_zones() to create tsunami-specific hazard and escape zones,
crop_roads_to_inner_extent() and make_road_aware_escape_zone() to prevent
false escape points along artificial study-area boundaries while retaining
bridge and walkway corridors, find_escape_points() to identify candidate
exits, make_conductance_surface() to build a slope-based conductance surface,
and run_evacpath() to run the full workflow.
Maintainer: Elvin Cordero [email protected]
Useful links:
Convert distance to evacuation time
calc_evac_time(distance_m, walking_speed_mps = 1.22, units = "minutes")calc_evac_time(distance_m, walking_speed_mps = 1.22, units = "minutes")
distance_m |
Distance in meters. |
walking_speed_mps |
Walking speed in meters per second. The paper-style default is 1.22 m/s, but this should be changed for local planning scenarios. |
units |
Output units: |
Numeric vector of evacuation times.
calc_evac_time(c(0, 120, 240), walking_speed_mps = 1.2)calc_evac_time(c(0, 120, 240), walking_speed_mps = 1.2)
For each origin point, calculates least-cost paths to all candidate safety points and stores the shortest finite path distance. Destination points are appended to the output with distance equal to zero.
calc_min_distance_to_safety( cs, origins, destinations, include_destinations = TRUE, progress = FALSE, progress_every = 1L, check_locations = FALSE, return_routes = FALSE )calc_min_distance_to_safety( cs, origins, destinations, include_destinations = TRUE, progress = FALSE, progress_every = 1L, check_locations = FALSE, return_routes = FALSE )
cs |
A |
origins |
Origin points. |
destinations |
Escape/safety destination points. |
include_destinations |
Logical. Add destination points with distance = 0. |
progress |
Logical. Print simple progress messages. |
progress_every |
Integer. Print progress every |
check_locations |
Logical passed to |
return_routes |
Logical. If |
A point SpatVector with columns distance and type. When
return_routes = TRUE, returns a list with distance_points, routes, and
unreachable_origins.
dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") cs <- make_conductance_surface(dem) origins <- terra::vect(data.frame(x = 0.5, y = 0.5), geom = c("x", "y"), crs = "EPSG:3857") destinations <- terra::vect(data.frame(x = 4.5, y = 4.5), geom = c("x", "y"), crs = "EPSG:3857") calc_min_distance_to_safety(cs, origins, destinations)dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") cs <- make_conductance_surface(dem) origins <- terra::vect(data.frame(x = 0.5, y = 0.5), geom = c("x", "y"), crs = "EPSG:3857") destinations <- terra::vect(data.frame(x = 4.5, y = 4.5), geom = c("x", "y"), crs = "EPSG:3857") calc_min_distance_to_safety(cs, origins, destinations)
Compatibility wrapper around leastcostpath::create_lcp() that returns NULL
when a path cannot be created.
calculate_lc_path(cs, origin, destination)calculate_lc_path(cs, origin, destination)
cs |
A |
origin |
Origin point. |
destination |
Destination point. |
A least-cost path object or NULL.
dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") cs <- make_conductance_surface(dem) origin <- terra::vect(data.frame(x = 0.5, y = 0.5), geom = c("x", "y"), crs = "EPSG:3857") destination <- terra::vect(data.frame(x = 4.5, y = 4.5), geom = c("x", "y"), crs = "EPSG:3857") calculate_lc_path(cs, origin, destination)dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") cs <- make_conductance_surface(dem) origin <- terra::vect(data.frame(x = 0.5, y = 0.5), geom = c("x", "y"), crs = "EPSG:3857") destination <- terra::vect(data.frame(x = 4.5, y = 4.5), geom = c("x", "y"), crs = "EPSG:3857") calculate_lc_path(cs, origin, destination)
Calculate the minimum path distance from a list of least-cost paths
calculate_min_dist(lc_paths_list)calculate_min_dist(lc_paths_list)
lc_paths_list |
A list of least-cost path line vectors. |
Minimum non-zero, finite path distance.
line <- terra::vect(matrix(c(0, 0, 1, 1), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") calculate_min_dist(list(line))line <- terra::vect(matrix(c(0, 0, 1, 1), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") calculate_min_dist(list(line))
Removes user-specified features from a road/pathway layer. This is useful for excluding piers, tunnels, private ways, or other features that should not be used in pedestrian evacuation modeling.
clean_roads(roads, exclude = NULL, target_crs = NULL)clean_roads(roads, exclude = NULL, target_crs = NULL)
roads |
A |
exclude |
Optional named list with |
target_crs |
Optional output CRS. |
A cleaned SpatVector.
roads <- terra::vect( list( matrix(c(0, 0, 0, 1), ncol = 2, byrow = TRUE), matrix(c(1, 0, 1, 1), ncol = 2, byrow = TRUE) ), type = "lines", crs = "EPSG:3857" ) roads$kind <- c("road", "pier") clean_roads(roads, exclude = list(field = "kind", values = "pier"))roads <- terra::vect( list( matrix(c(0, 0, 0, 1), ncol = 2, byrow = TRUE), matrix(c(1, 0, 1, 1), ncol = 2, byrow = TRUE) ), type = "lines", crs = "EPSG:3857" ) roads$kind <- c("road", "pier") clean_roads(roads, exclude = list(field = "kind", values = "pier"))
Runs run_evacpath() repeatedly across named scenario overrides and returns
scenario summaries with combined spatial outputs when those layers are
available.
compare_evac_scenarios( scenarios, ..., scenario_id_col = "scenario", keep_routes = FALSE, quiet = FALSE )compare_evac_scenarios( scenarios, ..., scenario_id_col = "scenario", keep_routes = FALSE, quiet = FALSE )
scenarios |
Named list. Each element is a named list of arguments that
override shared arguments passed through |
... |
Shared arguments passed to |
scenario_id_col |
Name of the scenario identifier column added to combined spatial outputs. |
keep_routes |
Logical. Retain selected least-cost routes in each scenario
result. Use |
quiet |
Logical. If |
An evac_scenario_comparison list with results, summary,
distance_points, time_polygons, and metadata.
dem <- terra::rast(nrows = 7, ncols = 7, xmin = 0, xmax = 7, ymin = 0, ymax = 7, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(terra::crop(dem, terra::ext(1, 6, 1, 6)), dissolve = TRUE) roads <- terra::vect(matrix(c(0, 3.5, 7, 3.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") comparison <- compare_evac_scenarios( scenarios = list(baseline = list(), slower = list(walking_speed_mps = 0.9)), hazard_zone = hazard, roads = roads, dem = dem, grid_resolution = 1, road_buffer_m = 0.2, escape_buffer_m = 0.3, final_road_buffer_m = 0.2, max_origins = 1, max_destinations = 2, seed = 1 ) comparison$summarydem <- terra::rast(nrows = 7, ncols = 7, xmin = 0, xmax = 7, ymin = 0, ymax = 7, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(terra::crop(dem, terra::ext(1, 6, 1, 6)), dissolve = TRUE) roads <- terra::vect(matrix(c(0, 3.5, 7, 3.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") comparison <- compare_evac_scenarios( scenarios = list(baseline = list(), slower = list(walking_speed_mps = 0.9)), hazard_zone = hazard, roads = roads, dem = dem, grid_resolution = 1, road_buffer_m = 0.2, escape_buffer_m = 0.3, final_road_buffer_m = 0.2, max_origins = 1, max_destinations = 2, seed = 1 ) comparison$summary
Crops a road/pathway layer to a slightly reduced bounding box around a zone. This is useful before escape-point detection because roads extending beyond the study-area coverage can intersect artificial raster or polygon extent edges and create false escape/safety points.
crop_roads_to_inner_extent(roads, zone, inset_x_m = 250, inset_y_m = 250)crop_roads_to_inner_extent(roads, zone, inset_x_m = 250, inset_y_m = 250)
roads |
Road/pathway network as a |
zone |
Zone used to define the outer extent. Can be a |
inset_x_m |
Numeric. Distance to inset the minimum and maximum x boundaries, in map units. Use meters when the data are projected. |
inset_y_m |
Numeric. Distance to inset the minimum and maximum y boundaries, in map units. Use meters when the data are projected. |
A cropped road/pathway SpatVector.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(-1, 2, 5, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") crop_roads_to_inner_extent(roads, zone, inset_x_m = 0.5, inset_y_m = 0)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(-1, 2, 5, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") crop_roads_to_inner_extent(roads, zone, inset_x_m = 0.5, inset_y_m = 0)
Runs spatial quality assurance and quality control checks before or after evacuation modeling. Unlike the modeling workflow, diagnostics collect issues into a report so several input problems can be reviewed together.
diagnose_evac_model( hazard_zone, roads, dem, target_crs = NULL, escape_zone = NULL, origins = NULL, destinations = NULL, conductance = NULL, check_reachability = TRUE, sample_size = 100, ... )diagnose_evac_model( hazard_zone, roads, dem, target_crs = NULL, escape_zone = NULL, origins = NULL, destinations = NULL, conductance = NULL, check_reachability = TRUE, sample_size = 100, ... )
hazard_zone |
Hazard-zone polygon, raster, or file path. |
roads |
Road/pathway line layer or file path. |
dem |
Digital elevation model raster or file path. |
target_crs |
Optional target coordinate reference system. |
escape_zone |
Optional escape-boundary zone. |
origins |
Optional modeled origin points. |
destinations |
Optional escape/safety destination points. |
conductance |
Optional |
check_reachability |
Logical. Attempt sampled routing checks when routing inputs are available. |
sample_size |
Maximum number of origins used for sampled reachability checks. |
... |
Reserved for future extensions. |
An evac_diagnostics list with issues, summary,
diagnostic_layers, and metadata.
dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(dem, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2.5, 5, 2.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") diagnostics <- diagnose_evac_model(hazard, roads, dem) diagnostics has_errors(diagnostics)dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(dem, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2.5, 5, 2.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") diagnostics <- diagnose_evac_model(hazard, roads, dem) diagnostics has_errors(diagnostics)
Intersects a road/pathway network with the boundary of the hazard zone and converts the intersection geometry to points. These points represent candidate exits from the hazard zone.
find_escape_points( hazard_zone, roads, study_area = NULL, region_buffer_m = 5000 )find_escape_points( hazard_zone, roads, study_area = NULL, region_buffer_m = 5000 )
hazard_zone |
Hazard/evacuation zone. |
roads |
Road/pathway network. |
study_area |
Optional local study area used to crop candidate escape points to a broader region around the study area. |
region_buffer_m |
Buffer distance passed to |
A point SpatVector of candidate escape/safety points.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(-1, 2, 5, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") find_escape_points(zone, roads)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(-1, 2, 5, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") find_escape_points(zone, roads)
Test whether diagnostics contain errors
has_errors(x, ...)has_errors(x, ...)
x |
An object returned by |
... |
Additional arguments passed to methods. |
Logical value indicating whether diagnostics contain at least one error.
dem <- terra::rast(nrows = 2, ncols = 2, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(dem, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 1, 2, 1), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") has_errors(diagnose_evac_model(hazard, roads, dem))dem <- terra::rast(nrows = 2, ncols = 2, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(dem, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 1, 2, 1), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") has_errors(diagnose_evac_model(hazard, roads, dem))
Uses thin-plate spline interpolation to create a continuous distance surface.
This preserves the original paper-script approach while keeping interpolation
optional. For most package workflows, make_evac_polygons() is the simpler
output.
interpolate_distance_surface( distance_points, region_area, study_area, resolution_coarse = 100, resolution_fine = 1, distance_col = "distance" )interpolate_distance_surface( distance_points, region_area, study_area, resolution_coarse = 100, resolution_fine = 1, distance_col = "distance" )
distance_points |
Point layer with a distance column. |
region_area |
Broader analysis region used for interpolation extent. |
study_area |
Final study area used to crop and mask the output. |
resolution_coarse |
Coarse interpolation resolution. |
resolution_fine |
Fine output resolution. |
distance_col |
Name of distance column in |
A SpatRaster distance surface.
if (requireNamespace("fields", quietly = TRUE)) { pts <- terra::vect( data.frame( x = c(0, 1, 0, 1, 0.5, 1.5), y = c(0, 0, 1, 1, 0.5, 1.5), distance = c(0, 5, 10, 15, 7, 20) ), geom = c("x", "y"), crs = "EPSG:3857" ) area <- terra::as.polygons(terra::rast(nrows = 2, ncols = 2, xmin = -1, xmax = 2, ymin = -1, ymax = 2, vals = 1, crs = "EPSG:3857"), dissolve = TRUE) interpolate_distance_surface(pts, area, area, resolution_coarse = 0.5, resolution_fine = 1) }if (requireNamespace("fields", quietly = TRUE)) { pts <- terra::vect( data.frame( x = c(0, 1, 0, 1, 0.5, 1.5), y = c(0, 0, 1, 1, 0.5, 1.5), distance = c(0, 5, 10, 15, 7, 20) ), geom = c("x", "y"), crs = "EPSG:3857" ) area <- terra::as.polygons(terra::rast(nrows = 2, ncols = 2, xmin = -1, xmax = 2, ymin = -1, ymax = 2, vals = 1, crs = "EPSG:3857"), dissolve = TRUE) interpolate_distance_surface(pts, area, area, resolution_coarse = 0.5, resolution_fine = 1) }
Masks a DEM to an optional road/pathway mask and creates a slope conductance
surface using leastcostpath.
make_conductance_surface( dem, road_mask = NULL, resolution = NULL, method = "slope", lcp_cost_function = "tobler", lcp_neighbours = 16, lcp_crit_slope = 12, lcp_max_slope = NULL, ... )make_conductance_surface( dem, road_mask = NULL, resolution = NULL, method = "slope", lcp_cost_function = "tobler", lcp_neighbours = 16, lcp_crit_slope = 12, lcp_max_slope = NULL, ... )
dem |
Elevation raster. |
road_mask |
Optional road/pathway mask. |
resolution |
Optional target DEM resolution before conductance creation. |
method |
Conductance method. Currently only |
lcp_cost_function |
Character string or function passed to
|
lcp_neighbours |
Neighbourhood passed to
|
lcp_crit_slope |
Numeric critical slope passed to
|
lcp_max_slope |
Optional numeric maximum slope passed to
|
... |
Additional named arguments passed to
|
A leastcostpath conductance surface object.
dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") make_conductance_surface(dem, lcp_neighbours = 8)dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") make_conductance_surface(dem, lcp_neighbours = 8)
Creates polygon grid cells over a hazard/evacuation zone and masks the grid to the zone. The resulting cells can be intersected with buffered roads to create road-based origin points.
make_evac_grid(hazard_zone, resolution)make_evac_grid(hazard_zone, resolution)
hazard_zone |
Hazard/evacuation zone as |
resolution |
Grid cell resolution in map units. Use meters when data are in a projected CRS. Can be length 1 or 2. |
A polygon SpatVector grid clipped/masked to the hazard zone.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) make_evac_grid(zone, resolution = 1)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) make_evac_grid(zone, resolution = 1)
Creates Voronoi polygons from least-cost distance points, converts distance to travel time, and optionally clips the output to an inundated road/study mask.
make_evac_polygons( distance_points, clip_area = NULL, walking_speed_mps = 1.22, region_name = NULL, distance_col = "DistToSafety", time_col = "EvacTimeAvg" )make_evac_polygons( distance_points, clip_area = NULL, walking_speed_mps = 1.22, region_name = NULL, distance_col = "DistToSafety", time_col = "EvacTimeAvg" )
distance_points |
Point output from |
clip_area |
Optional polygon used to crop the Voronoi output. |
walking_speed_mps |
Walking speed in meters per second. |
region_name |
Optional region/municipality name stored in the output. |
distance_col |
Name of the output distance column. |
time_col |
Name of the output time column. |
A polygon SpatVector.
pts <- terra::vect( data.frame(x = c(0, 1, 0, 1), y = c(0, 0, 1, 1), distance = c(0, 5, 10, 15)), geom = c("x", "y"), crs = "EPSG:3857" ) clip <- terra::as.polygons(terra::rast(nrows = 2, ncols = 2, xmin = -1, xmax = 2, ymin = -1, ymax = 2, vals = 1, crs = "EPSG:3857"), dissolve = TRUE) make_evac_polygons(pts, clip_area = clip)pts <- terra::vect( data.frame(x = c(0, 1, 0, 1), y = c(0, 0, 1, 1), distance = c(0, 5, 10, 15)), geom = c("x", "y"), crs = "EPSG:3857" ) clip <- terra::as.polygons(terra::rast(nrows = 2, ncols = 2, xmin = -1, xmax = 2, ymin = -1, ymax = 2, vals = 1, crs = "EPSG:3857"), dissolve = TRUE) make_evac_polygons(pts, clip_area = clip)
Make an output clip area for evacuation polygons
make_output_clip_area( hazard_zone, roads_buffer, final_road_buffer_m = 3, clip_mode = c("hazard", "road_hazard", "hazard_plus_roads", "none") )make_output_clip_area( hazard_zone, roads_buffer, final_road_buffer_m = 3, clip_mode = c("hazard", "road_hazard", "hazard_plus_roads", "none") )
hazard_zone |
Hazard zone polygon. |
roads_buffer |
Buffered roads. |
final_road_buffer_m |
Additional road buffer for output clipping. |
clip_mode |
One of |
A SpatVector clip area or NULL.
Dissolves the full hazard zone, buffers a smaller study area, and crops the full zone to that buffer. This is useful when escape/safety points outside a municipality or local study area should still be considered.
make_region_area(hazard_zone, study_area, buffer_m = 5000)make_region_area(hazard_zone, study_area, buffer_m = 5000)
hazard_zone |
Full hazard/evacuation zone. |
study_area |
Local study area. |
buffer_m |
Buffer distance in map units, typically meters. |
A polygon SpatVector for the broader analysis region.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) study <- terra::as.polygons(terra::crop(r, terra::ext(1, 3, 1, 3)), dissolve = TRUE) make_region_area(zone, study, buffer_m = 1)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) study <- terra::as.polygons(terra::crop(r, terra::ext(1, 3, 1, 3)), dissolve = TRUE) make_region_area(zone, study, buffer_m = 1)
Creates a road-aware escape zone by combining a base escape zone with buffered
road/pathway corridors. This is useful for tsunami workflows in coastal cities
where bridges, causeways, or other walkways over water can be lost when the
inundation layer is split into land and water masks. The resulting object can
be passed to find_escape_points() so escape/safety points are generated from
a boundary that includes relevant road corridors as well as the tsunami zone.
make_road_aware_escape_zone( escape_zone, roads, road_buffer_m = 2, crop_buffer_m = 3, include_base_zone = TRUE )make_road_aware_escape_zone( escape_zone, roads, road_buffer_m = 2, crop_buffer_m = 3, include_base_zone = TRUE )
escape_zone |
Base escape-boundary zone, usually the land-inundation-plus-
water zone from |
roads |
Road/pathway network used to create the road-aware corridor. |
road_buffer_m |
First road buffer distance in map units. |
crop_buffer_m |
Optional second buffer applied before cropping/combining. |
include_base_zone |
Logical. If |
A dissolved SpatVector escape-boundary zone.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2, 4, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") make_road_aware_escape_zone(zone, roads, road_buffer_m = 0.1)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2, 4, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") make_road_aware_escape_zone(zone, roads, road_buffer_m = 0.1)
Buffers the road network and candidate escape points, combines those buffered areas, and dissolves the result. The mask is used to constrain least-cost movement to the road/pathway network while allowing access around escape locations.
make_road_mask( roads, escape_points, road_buffer_m = 2, escape_buffer_m = 5, return_components = FALSE )make_road_mask( roads, escape_points, road_buffer_m = 2, escape_buffer_m = 5, return_components = FALSE )
roads |
Road/pathway network. |
escape_points |
Candidate escape/safety points. |
road_buffer_m |
Road buffer distance in map units, typically meters. |
escape_buffer_m |
Escape-point buffer distance in map units, typically meters. |
return_components |
Logical. If |
A dissolved road mask SpatVector, or a list when return_components = TRUE.
roads <- terra::vect(matrix(c(0, 1, 4, 1), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") escape <- terra::vect(data.frame(x = 4, y = 1), geom = c("x", "y"), crs = "EPSG:3857") make_road_mask(roads, escape, road_buffer_m = 0.1, escape_buffer_m = 0.2)roads <- terra::vect(matrix(c(0, 1, 4, 1), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") escape <- terra::vect(data.frame(x = 4, y = 1), geom = c("x", "y"), crs = "EPSG:3857") make_road_mask(roads, escape, road_buffer_m = 0.1, escape_buffer_m = 0.2)
Intersects an evacuation grid with a buffered road network and converts the resulting road-crossing cell geometry to points.
make_road_origins( evac_grid, roads_buffer, hazard_zone = NULL, max_origins = NULL, seed = NULL )make_road_origins( evac_grid, roads_buffer, hazard_zone = NULL, max_origins = NULL, seed = NULL )
evac_grid |
Polygon grid from |
roads_buffer |
Buffered road/pathway network. |
hazard_zone |
Optional hazard-zone polygon used to crop candidate origins after intersecting the grid with the road buffer. |
max_origins |
Optional maximum number of origin points to retain. Useful for large regions or exploratory runs. |
seed |
Random seed used when |
A point SpatVector of road-based evacuation origins.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") grid <- make_evac_grid(terra::as.polygons(r, dissolve = TRUE), resolution = 1) roads <- terra::vect(matrix(c(0, 2, 4, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") roads_buffer <- terra::buffer(roads, 0.2) make_road_origins(grid, roads_buffer, hazard_zone = terra::as.polygons(r, dissolve = TRUE), max_origins = 3, seed = 1)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") grid <- make_evac_grid(terra::as.polygons(r, dissolve = TRUE), resolution = 1) roads <- terra::vect(matrix(c(0, 2, 4, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") roads_buffer <- terra::buffer(roads, 0.2) make_road_origins(grid, roads_buffer, hazard_zone = terra::as.polygons(r, dissolve = TRUE), max_origins = 3, seed = 1)
Mirrors the original script logic where roads were buffered, optionally buffered again for tolerance, cropped to the inundation zone, and then combined with the zone. This is useful for quality assurance and quality control and for reproducing the earlier road-plus-inundation analysis area.
make_roads_in_zone( roads, zone, road_buffer_m = 2, crop_buffer_m = 3, include_zone = TRUE )make_roads_in_zone( roads, zone, road_buffer_m = 2, crop_buffer_m = 3, include_zone = TRUE )
roads |
Road/pathway network. |
zone |
Polygon/raster zone used to crop buffered roads. |
road_buffer_m |
First road buffer distance. |
crop_buffer_m |
Optional second buffer applied before cropping. |
include_zone |
Logical. If |
A SpatVector.
r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2, 4, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") make_roads_in_zone(roads, zone, road_buffer_m = 0.1)r <- terra::rast(nrows = 4, ncols = 4, xmin = 0, xmax = 4, ymin = 0, ymax = 4, vals = 1, crs = "EPSG:3857") zone <- terra::as.polygons(r, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2, 4, 2), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") make_roads_in_zone(roads, zone, road_buffer_m = 0.1)
Creates a route-density raster and identifies high-use modeled evacuation
corridors from supplied least-cost paths or an run_evacpath() result created
with keep_routes = TRUE.
map_evac_bottlenecks( routes = NULL, evac_result = NULL, template = NULL, quantile_threshold = 0.9, min_count = NULL, rescale = FALSE, return_polygons = TRUE, ... )map_evac_bottlenecks( routes = NULL, evac_result = NULL, template = NULL, quantile_threshold = 0.9, min_count = NULL, rescale = FALSE, return_polygons = TRUE, ... )
routes |
An |
evac_result |
Optional output from |
template |
Optional |
quantile_threshold |
Numeric value between |
min_count |
Optional numeric minimum density count. When supplied, this
takes precedence over |
rescale |
Logical passed to |
return_polygons |
Logical. Convert high-density raster cells to polygons. |
... |
Reserved for future extensions. |
An evac_bottleneck list with density rasters, optional polygons,
threshold value, and summary.
template <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") routes <- sf::st_sf( route = c("a", "b"), geometry = sf::st_sfc( sf::st_linestring(matrix(c(0.5, 0.5, 4.5, 4.5), ncol = 2, byrow = TRUE)), sf::st_linestring(matrix(c(0.5, 4.5, 4.5, 0.5), ncol = 2, byrow = TRUE)), crs = 3857 ) ) map_evac_bottlenecks(routes = routes, template = template)template <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") routes <- sf::st_sf( route = c("a", "b"), geometry = sf::st_sfc( sf::st_linestring(matrix(c(0.5, 0.5, 4.5, 4.5), ncol = 2, byrow = TRUE)), sf::st_linestring(matrix(c(0.5, 4.5, 4.5, 0.5), ncol = 2, byrow = TRUE)), crs = 3857 ) ) map_evac_bottlenecks(routes = routes, template = template)
Read and project the core evacuation inputs
prepare_evac_inputs( hazard_zone, roads, dem, target_crs = NULL, hazard_as_polygon = TRUE, dissolve_hazard = TRUE, road_exclude = NULL )prepare_evac_inputs( hazard_zone, roads, dem, target_crs = NULL, hazard_as_polygon = TRUE, dissolve_hazard = TRUE, road_exclude = NULL )
hazard_zone |
Hazard/inundation zone as a |
roads |
Road/pathway network as a |
dem |
Elevation raster as a |
target_crs |
Optional projected CRS in meters. |
hazard_as_polygon |
Logical. Convert raster hazard zones to polygons. |
dissolve_hazard |
Logical. Dissolve hazard polygon pieces. |
road_exclude |
Optional road exclusion list passed to |
A named list with hazard_zone, roads, and dem.
dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(dem, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2.5, 5, 2.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") inputs <- prepare_evac_inputs(hazard, roads, dem) names(inputs)dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5, vals = 1, crs = "EPSG:3857") hazard <- terra::as.polygons(dem, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 2.5, 5, 2.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") inputs <- prepare_evac_inputs(hazard, roads, dem) names(inputs)
Converts an inundation raster to a binary hazard-zone raster or polygon using a threshold. This is intentionally general so users can adapt it to tsunami, flood, storm-surge, or other hazard layers.
prepare_hazard_zone( inundation, threshold = 0, land_mask = NULL, target_crs = NULL, as_polygon = TRUE, dissolve = TRUE )prepare_hazard_zone( inundation, threshold = 0, land_mask = NULL, target_crs = NULL, as_polygon = TRUE, dissolve = TRUE )
inundation |
A |
threshold |
Numeric threshold. Cells greater than |
land_mask |
Optional |
target_crs |
Optional output CRS. Use a projected CRS in meters for later distance calculations. |
as_polygon |
Logical. If |
dissolve |
Logical. If |
A binary SpatRaster or polygon SpatVector.
r <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5) terra::values(r) <- c(rep(0, 12), rep(1, 13)) zone <- prepare_hazard_zone(r, threshold = 0, as_polygon = TRUE) zoner <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5) terra::values(r) <- c(rep(0, 12), rep(1, 13)) zone <- prepare_hazard_zone(r, threshold = 0, as_polygon = TRUE) zone
Tsunami evacuation workflows often need two different zone objects. The land-only inundation zone is the area where road origins and output time surfaces should be mapped. The escape-boundary zone should combine the land-only inundation zone with water so that the coastline is not treated as an artificial escape boundary. This prevents false escape/safety points along the water-land edge when roads touch or approach the shoreline.
prepare_tsunami_zones( inundation, dem, target_crs = NULL, inundation_threshold = 0, land_threshold = 0, water_threshold = 0, dem_sign_multiplier = 1, resample_method = "bilinear", as_polygon = TRUE, dissolve = TRUE )prepare_tsunami_zones( inundation, dem, target_crs = NULL, inundation_threshold = 0, land_threshold = 0, water_threshold = 0, dem_sign_multiplier = 1, resample_method = "bilinear", as_polygon = TRUE, dissolve = TRUE )
inundation |
Inundation-depth raster or path to a raster. Cells greater
than |
dem |
Elevation/topobathymetry raster or path to a raster. |
target_crs |
Optional projected CRS in meters for returned objects. |
inundation_threshold |
Numeric threshold used to define inundated cells. |
land_threshold |
Numeric DEM threshold used to define land. Default is
|
water_threshold |
Numeric DEM threshold used to define water. Default is
|
dem_sign_multiplier |
Multiplier applied to the DEM before land/water
classification. Use |
resample_method |
Method passed to |
as_polygon |
Logical. If |
dissolve |
Logical. Dissolve polygon pieces. |
A named list with land-only hazard_zone, water-combined
escape_zone, and supporting rasters. hazard_zone should usually be used
for origin generation, mapping, and output clipping. escape_zone should
usually be passed to run_evacpath(escape_zone = ...) or
find_escape_points().
dem <- terra::rast(nrows = 6, ncols = 6, xmin = 0, xmax = 6, ymin = 0, ymax = 6, crs = "EPSG:3857") xy <- terra::crds(dem, df = TRUE) terra::values(dem) <- -1.5 + 0.7 * xy$x + 0.2 * sin(xy$y) inundation <- dem terra::values(inundation) <- ifelse(terra::values(dem) > 0 & terra::values(dem) < 2.5, 1, 0) zones <- prepare_tsunami_zones(inundation, dem, as_polygon = TRUE) names(zones)dem <- terra::rast(nrows = 6, ncols = 6, xmin = 0, xmax = 6, ymin = 0, ymax = 6, crs = "EPSG:3857") xy <- terra::crds(dem, df = TRUE) terra::values(dem) <- -1.5 + 0.7 * xy$x + 0.2 * sin(xy$y) inundation <- dem terra::values(inundation) <- ifelse(terra::values(dem) > 0 & terra::values(dem) < 2.5, 1, 0) zones <- prepare_tsunami_zones(inundation, dem, as_polygon = TRUE) names(zones)
Accepts an existing terra object or a file path and returns a SpatRaster
or SpatVector. Raster-like extensions are read with terra::rast() and
vector-like extensions are read with terra::vect().
read_spatial(x)read_spatial(x)
x |
A |
A SpatRaster or SpatVector.
r <- terra::rast(nrows = 2, ncols = 2, vals = 1) read_spatial(r)r <- terra::rast(nrows = 2, ncols = 2, vals = 1) read_spatial(r)
This high-level wrapper runs the core evacpath pipeline: read/project inputs,
create an evacuation grid, identify escape/safety points, build a road mask,
create a slope-based conductance surface, calculate minimum least-cost distance
to safety, and create evacuation-time polygons.
run_evacpath( hazard_zone, roads, dem, target_crs = NULL, region_name = NULL, escape_zone = NULL, roads_for_escape = NULL, escape_roads_inset_x_m = 0, escape_roads_inset_y_m = 0, road_aware_escape_zone = FALSE, escape_zone_road_buffer_m = NULL, escape_zone_crop_buffer_m = NULL, study_area = NULL, road_exclude = NULL, grid_resolution = NULL, grid_resolution_factor = 5, road_buffer_m = 2, escape_buffer_m = 5, final_road_buffer_m = 3, region_buffer_m = 5000, dem_resolution = NULL, max_origins = NULL, max_destinations = NULL, seed = 23401, walking_speed_mps = 1.22, lcp_cost_function = "tobler", lcp_neighbours = 16, lcp_crit_slope = 12, lcp_max_slope = NULL, lcp_args = list(), clip_mode = c("hazard", "road_hazard", "hazard_plus_roads", "none"), progress = FALSE, progress_every = 1L, lcp_check_locations = FALSE, keep_routes = FALSE )run_evacpath( hazard_zone, roads, dem, target_crs = NULL, region_name = NULL, escape_zone = NULL, roads_for_escape = NULL, escape_roads_inset_x_m = 0, escape_roads_inset_y_m = 0, road_aware_escape_zone = FALSE, escape_zone_road_buffer_m = NULL, escape_zone_crop_buffer_m = NULL, study_area = NULL, road_exclude = NULL, grid_resolution = NULL, grid_resolution_factor = 5, road_buffer_m = 2, escape_buffer_m = 5, final_road_buffer_m = 3, region_buffer_m = 5000, dem_resolution = NULL, max_origins = NULL, max_destinations = NULL, seed = 23401, walking_speed_mps = 1.22, lcp_cost_function = "tobler", lcp_neighbours = 16, lcp_crit_slope = 12, lcp_max_slope = NULL, lcp_args = list(), clip_mode = c("hazard", "road_hazard", "hazard_plus_roads", "none"), progress = FALSE, progress_every = 1L, lcp_check_locations = FALSE, keep_routes = FALSE )
hazard_zone |
Hazard/inundation zone as |
roads |
Road/pathway network as |
dem |
Elevation raster as |
target_crs |
Optional projected CRS in meters, for example |
region_name |
Optional region name stored in output polygons. |
escape_zone |
Optional boundary zone used only to identify escape/safety
points. For tsunami workflows, pass the land-inundation-plus-water zone from
|
roads_for_escape |
Optional road/pathway layer used only for escape-point
detection. If |
escape_roads_inset_x_m |
Optional x-direction inset applied to
|
escape_roads_inset_y_m |
Optional y-direction inset applied to
|
road_aware_escape_zone |
Logical. If |
escape_zone_road_buffer_m |
Road buffer used when |
escape_zone_crop_buffer_m |
Additional buffer used when |
study_area |
Optional local study area for limiting escape-point search. |
road_exclude |
Optional list passed to |
grid_resolution |
Evacuation-grid resolution. If |
grid_resolution_factor |
Multiplier applied to DEM resolution when
|
road_buffer_m |
Road buffer distance. |
escape_buffer_m |
Escape-point buffer distance. |
final_road_buffer_m |
Output clipping buffer around roads. |
region_buffer_m |
Buffer around |
dem_resolution |
Optional DEM resolution used before conductance creation. |
max_origins |
Optional maximum number of road origin points. |
max_destinations |
Optional maximum number of escape/safety destination points. This is useful for quick tests in regions where roads intersect the hazard boundary many times. |
seed |
Random seed used when |
walking_speed_mps |
Walking speed in meters per second. This controls conversion of modeled route distances into evacuation times. It does not change route geometry. |
lcp_cost_function |
Character string or function passed to
|
lcp_neighbours |
Neighbourhood passed to
|
lcp_crit_slope |
Numeric critical slope passed to
|
lcp_max_slope |
Optional numeric maximum traversable slope passed to
|
lcp_args |
Named list of additional arguments passed to
|
clip_mode |
Output clipping mode. The default |
progress |
Logical. Print progress while running least-cost paths. |
progress_every |
Integer. Print progress every |
lcp_check_locations |
Logical passed to |
keep_routes |
Logical. If |
For tsunami applications, hazard_zone and escape_zone should often be
different. Use a land-only hazard_zone for origins and output mapping, but
use a water-combined escape_zone for escape-point detection so the coastline
is not treated as an artificial safety boundary. The helper
prepare_tsunami_zones() creates both objects.
An evacpath_result list containing spatial outputs and parameters.
dem <- terra::rast(nrows = 7, ncols = 7, xmin = 0, xmax = 7, ymin = 0, ymax = 7, vals = 1, crs = "EPSG:3857") hazard_raster <- terra::crop(dem, terra::ext(1, 6, 1, 6)) hazard <- terra::as.polygons(hazard_raster, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 3.5, 7, 3.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") result <- run_evacpath( hazard_zone = hazard, roads = roads, dem = dem, grid_resolution = 1, road_buffer_m = 0.2, escape_buffer_m = 0.3, final_road_buffer_m = 0.2, max_origins = 2, max_destinations = 2, seed = 1 ) resultdem <- terra::rast(nrows = 7, ncols = 7, xmin = 0, xmax = 7, ymin = 0, ymax = 7, vals = 1, crs = "EPSG:3857") hazard_raster <- terra::crop(dem, terra::ext(1, 6, 1, 6)) hazard <- terra::as.polygons(hazard_raster, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 3.5, 7, 3.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") result <- run_evacpath( hazard_zone = hazard, roads = roads, dem = dem, grid_resolution = 1, road_buffer_m = 0.2, escape_buffer_m = 0.3, final_road_buffer_m = 0.2, max_origins = 2, max_destinations = 2, seed = 1 ) result
Compares modeled routes with official, observed, collaborator-provided, or
manually digitized reference routes. Buffer overlap and Hausdorff-distance
comparisons are calculated with sf. Path deviation index comparisons use
leastcostpath::PDI_validation() when available and compatible with the
supplied routes.
validate_evac_routes( modeled_routes, reference_routes, method = c("pdi", "buffer_overlap", "hausdorff", "all"), buffer_m = 25, by = NULL, ... )validate_evac_routes( modeled_routes, reference_routes, method = c("pdi", "buffer_overlap", "hausdorff", "all"), buffer_m = 25, by = NULL, ... )
modeled_routes |
An |
reference_routes |
An |
method |
Comparison method: |
buffer_m |
Buffer distance in projected coordinate reference system units, typically meters. |
by |
Optional column name used to match modeled and reference routes.
When |
... |
Reserved for future extensions. |
An evac_route_validation list with route-level metrics,
matched_routes, requested method, buffer_m, and summary.
modeled <- sf::st_sf( id = "route_a", geometry = sf::st_sfc( sf::st_linestring(matrix(c(0, 0, 100, 0), ncol = 2, byrow = TRUE)), crs = 3857 ) ) reference <- sf::st_sf( id = "route_a", geometry = sf::st_sfc( sf::st_linestring(matrix(c(0, 5, 100, 5), ncol = 2, byrow = TRUE)), crs = 3857 ) ) validate_evac_routes(modeled, reference, method = "buffer_overlap", buffer_m = 10)modeled <- sf::st_sf( id = "route_a", geometry = sf::st_sfc( sf::st_linestring(matrix(c(0, 0, 100, 0), ncol = 2, byrow = TRUE)), crs = 3857 ) ) reference <- sf::st_sf( id = "route_a", geometry = sf::st_sfc( sf::st_linestring(matrix(c(0, 5, 100, 5), ncol = 2, byrow = TRUE)), crs = 3857 ) ) validate_evac_routes(modeled, reference, method = "buffer_overlap", buffer_m = 10)
Writes the main spatial outputs in an evacpath_result list to GeoPackage and
GeoTIFF files. Non-spatial objects, including the conductance surface, are not
written.
write_evac_outputs( result, output_dir, prefix = "evacpath", overwrite = TRUE, include_inputs = FALSE )write_evac_outputs( result, output_dir, prefix = "evacpath", overwrite = TRUE, include_inputs = FALSE )
result |
An object returned by |
output_dir |
Output directory. |
prefix |
Filename prefix. |
overwrite |
Logical. Overwrite existing files. |
include_inputs |
Logical. Also write projected input layers. |
A named character vector of written file paths.
dem <- terra::rast(nrows = 7, ncols = 7, xmin = 0, xmax = 7, ymin = 0, ymax = 7, vals = 1, crs = "EPSG:3857") hazard_raster <- terra::crop(dem, terra::ext(1, 6, 1, 6)) hazard <- terra::as.polygons(hazard_raster, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 3.5, 7, 3.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") result <- run_evacpath( hazard_zone = hazard, roads = roads, dem = dem, grid_resolution = 1, road_buffer_m = 0.2, escape_buffer_m = 0.3, final_road_buffer_m = 0.2, max_origins = 2, max_destinations = 2, seed = 1 ) out_dir <- file.path(tempdir(), "evacpath-example") paths <- write_evac_outputs(result, output_dir = out_dir, prefix = "example") unlink(out_dir, recursive = TRUE)dem <- terra::rast(nrows = 7, ncols = 7, xmin = 0, xmax = 7, ymin = 0, ymax = 7, vals = 1, crs = "EPSG:3857") hazard_raster <- terra::crop(dem, terra::ext(1, 6, 1, 6)) hazard <- terra::as.polygons(hazard_raster, dissolve = TRUE) roads <- terra::vect(matrix(c(0, 3.5, 7, 3.5), ncol = 2, byrow = TRUE), type = "lines", crs = "EPSG:3857") result <- run_evacpath( hazard_zone = hazard, roads = roads, dem = dem, grid_resolution = 1, road_buffer_m = 0.2, escape_buffer_m = 0.3, final_road_buffer_m = 0.2, max_origins = 2, max_destinations = 2, seed = 1 ) out_dir <- file.path(tempdir(), "evacpath-example") paths <- write_evac_outputs(result, output_dir = out_dir, prefix = "example") unlink(out_dir, recursive = TRUE)