Converts user-supplied or downloaded spatial street data into a clean, pedestrian-routing graph structure. Computes edge travel times at a constant walking speed, optionally performs geometric repairs (planarization, endpoint snapping) at the user's discretion, and prepares Compressed Sparse Row (CSR) topology via compiled Rust.
Arguments
- data
An
sfobject withLINESTRINGorMULTILINESTRINGgeometries.- crs
Optional target metric CRS (e.g.
EPSG:32722or"auto"to automatically infer the appropriate local UTM zone). If provided anddatais in a different CRS, it will be projected.- walk_speed_kmh
Walking design speed in km/h (default is 4.5 km/h, the international pedestrian planning standard, approx. 1.25 m/s).
- repair
Logical. If
TRUE, applies the requested topological cleaning (planarize,snap_tolerance_m). IfFALSE, preserves geometry exactly as provided.- planarize
Logical. If
TRUEandrepair = TRUE, splits crossing lines at intersections to create valid routing junctions.- snap_tolerance_m
Numeric. Threshold in meters to snap endpoint gaps. Default is 0.0 (no snapping). A value between 2.0 and 5.0 is recommended for imperfect street databases.
- keep_components
Character. Either
"largest"(default) to extract the main connected pedestrian network, or"all"to retain disconnected fragments.- drop_classes
Character vector of road classes to exclude (e.g.
c("motorway", "trunk")). Only applied if aclassorhighwaycolumn is present indata.- drop_subclasses
Logical. If
TRUE, drops non-network subclasses like sidewalk, crosswalk, cycle_crossing, driveway, and parking_aisle if metadata exists.- verbose
Logical. If
TRUE, prints a summary of network construction.
Value
A walk_network S3 object containing:
- nodes
sfpoint collection with node coordinates and IDs.- edges
sfline collection withlength_m,travel_time_s, from-node, to-node.- csr
List with Compressed Sparse Row topology arrays (
head,to,wt,wl,comp).- walk_speed_kmh
The walking speed used.
- giant_comp_id
ID of the giant connected component.
- crs
The coordinate reference system of the network.
Examples
data(streets_cusco)
net <- walk_build_network(streets_cusco, verbose = FALSE)
print(net)
#>
#> ── Walkability Network ─────────────────────────────────────────────────────────
#> ✔ Total nodes: 562 (Giant component: 249)
#> ✔ Total edges: 288 segments (27.3 km)
#> ✔ Walking speed: 4.5 km/h (1.25 m/s)
#> ✔ Connected components: 125
#> ✔ CRS: EPSG:32719