Network Analysis

Network analysis in WbW-QGIS spans both transportation and hydrologic networks. This chapter is aligned with the Python and R manuals and now covers three common tracks:

  • Transportation routing and service areas
  • OD and nearest-facility analysis
  • Stream-network hierarchy and connectivity

Core Concepts You Should Know First

  • Network: A graph of edges (line segments) and nodes (junctions/endpoints).
  • Cost or impedance: Value minimized by routing (distance, minutes, or other weighted friction).
  • OD pair: Origin and destination used in path queries.
  • Service area: All network locations reachable under a cost budget.
  • Closest facility: Nearest destination by network cost, not straight-line distance.
  • Connectivity: Whether all required features are in connected components.
  • Directed network: Edge direction matters (one-way roads, downstream streams).

Typical Inputs

LayerFormatNotes
roads.shpPolyline vectorCleaned road centerlines
facilities.shpPoint vectorHospitals, depots, schools, etc.
demand_points.shpPoint vectorIncidents, customers, or population centroids
streams.tifRasterBinary stream raster for hydrologic hierarchy
d8_pointer.tifRasterD8 flow-direction raster

Workflow A: Transportation Network Preparation

Step 1 - Topology QA and Geometry Cleanup

Use standard QGIS cleanup first:

  • Check validity
  • Snap Geometries to Layer
  • Fix Geometries

Then enrich network attributes with Whitebox tools:

Processing Toolbox -> Whitebox Workflows -> Vector Analysis -> Add Geometry Attributes

This provides segment length fields needed for distance-based routing.

If travel-time routing is required, compute a time field such as:

  • TIME_MIN = LENGTH_M / SPEED_M_PER_MIN

using Field Calculator.


Step 2 - Build Cost-Aware Road Layer

Recommended fields:

  • LENGTH_M (meters)
  • SPEED_KMH (if available)
  • TIME_MIN (derived)
  • ONEWAY (optional directional control)

Use this prepared layer as the routing network for native QGIS algorithms.


Step 2.5 - Build Network Topology and Snap Points (Optional)

If your network lacks proper node structure or you need to snap facility/demand points to the network:

Processing Toolbox → Whitebox Workflows → Vector Analysis → Build Network Topology

ParameterValue
Input vectorroads_prepared.shp
Snap tolerance0.5
Outputroads_noded.shp
Output nodesnetwork_nodes.shp

Then snap your facilities and demand points:

Processing Toolbox → Whitebox Workflows → Vector Analysis → Snap Points to Network

ParameterValue
Network layerroads_noded.shp
Points layerfire_stations.shp
Snap distance50.0 (meters)
Outputfire_stations_snapped.shp

Output includes SNAP_DIST (offset to network) for diagnostics.


Workflow B: Routing, Service Areas, and Closest Facility

Step 3 - Shortest Path

Processing Toolbox -> Network Analysis:

  • Shortest Path (Point to Point)
  • Shortest Path (Layer to Point)
  • Shortest Path (Point to Layer)

Use the prepared cost field (distance or time) consistently.


Step 4 - Service Area (Isochrone)

Processing Toolbox -> Network Analysis -> Service Area (From Layer)

Recommended parameters:

ParameterExample
Network layerroads_prepared.shp
StrategyShortest
Start pointsfacilities.shp
Travel cost5.0 (minutes) or 3000 (meters)

Export output lines and optional polygons for reporting.


Step 5 - Closest Facility Pattern

Use Service Area and shortest-path tools together:

  • Build candidate facilities
  • Route demand points to nearest reachable facilities
  • Summarize cost by facility catchment

For large batches, run model-builder or Python Console loops.


Workflow C: OD-Style Batch Analysis in QGIS

QGIS does not provide a single OD matrix tool equivalent to the Python/R chapters, so the standard QGIS pattern is:

  • Iterate origins and destinations in batch
  • Run shortest path for each pair
  • Aggregate travel cost in an output table

Use this when you need accessibility summaries or assignment baselines directly inside QGIS projects.


Workflow D: Hydrologic Stream Networks

Hydrologic network tools remain an important part of network analysis and are included here as a dedicated sub-workflow rather than the entire chapter.

Step 6 - Stream Hierarchy

Processing Toolbox -> Whitebox Workflows -> Spatial Hydrology:

  • Strahler Stream Order
  • Shreve Stream Magnitude
  • Hack Stream Order

These tools characterize stream position and downstream accumulation.

Step 7 - Stream Vectorization

Processing Toolbox -> Whitebox Workflows -> Spatial Hydrology -> Raster Streams to Vector

Convert ordered stream rasters to vector lines for cartography and further network operations.


QGIS Python Console Equivalent

import processing

# Add geometry attributes for road cost preparation
processing.run('whitebox_workflows:add_geometry_attributes', {
    'input': '/data/roads.shp',
    'output': '/data/roads_prepared.shp',
})

# Service area from facilities
processing.run('native:serviceareafromlayer', {
    'INPUT': '/data/roads_prepared.shp',
    'STRATEGY': 0,
    'START_POINTS': '/data/facilities.shp',
    'TRAVEL_COST': 5.0,
    'OUTPUT_LINES': '/data/service_area_lines.shp',
    'OUTPUT': 'TEMPORARY_OUTPUT',
})

# Stream order
processing.run('whitebox_workflows:strahler_stream_order', {
    'd8_pntr': '/data/d8_pointer.tif',
    'streams': '/data/streams.tif',
    'output': '/data/strahler.tif',
})

Common Pitfalls

ProblemLikely causeFix
No route found between known-connected pointsTopology gaps or unsnapped endpointsRun snapping and revalidate connectivity
Service area too small or too largeCost units inconsistentKeep all costs in either meters or minutes
One-way streets ignoredDirection field not configuredVerify direction settings in network algorithm
Batch routing is slowUnnecessary repeated reprojection or heavy geometryPreprocess to common CRS and simplify where appropriate
Stream order appears uniformBad stream threshold or mismatched d8/stream rastersRebuild streams and ensure matching extent/grid

Validation Checklist

  • Routing network passes geometry validity and snapping checks.
  • Cost field units are consistent across all analyses.
  • Directionality assumptions are documented (directed vs undirected).
  • Service-area outputs were spot-checked against known travel behavior.
  • Stream-order outputs were checked at confluences.
  • Workflow parameters were saved in model or processing history.