Elevation Pipeline¶
Last updated: November 2026
NOTE : This describes my custom algorithm and workflow which takes OSM and elevation data as input and outputs a graph. Crestr no longer uses this, as it was replaced with a BRouter service. You can still find this in the Legacy Repository
This document explains how Crestr enriches the pathfinding graph with elevation data and uses it to produce realistic hiking times and route costs.
Overview¶
The elevation pipeline is a one-time preprocessing step that:
- Attaches accurate elevation values to every node in the graph.
- Calculates realistic travel times for every edge using an enhanced version of Naismith's Rule.
- Adjusts costs based on terrain difficulty, surface type, and trail visibility.
The result is a elevated_populated_igraph.pkl file that the routing engine uses for A* pathfinding.
Process Steps¶
1. Node Elevation Assignment¶
- All node coordinates (stored in Web Mercator) are converted to WGS84.
- A digital elevation model (DEM) raster (
Cumbria-Elevation-File.tif) is sampled at every node location usingrasterio. - Elevation values (in metres) are attached directly to each node as the
elevattribute. - NoData values are replaced with 0.
2. Edge Enrichment¶
For every edge in the graph, the pipeline performs the following calculations:
Horizontal Distance Correction¶
- Accounts for Web Mercator distortion using the cosine of the midpoint latitude.
Elevation Difference & Slope¶
- Computes the vertical gain/loss and slope ratio between the two nodes.
Naismith's Rule (Enhanced)¶
Calculates realistic travel time by combining:
- Flat walking time based on adjusted speed
- Additional time for ascent (+10m = +1 minute)
- Additional time for descent (+7.5m = +1 minute)
Walking speed is dynamically adjusted according to slope steepness:
- less than 5°: 1.4 m/s (gentle)
- 5–12°: 1.1 m/s (moderate)
- 12–25°: 0.8 m/s (steep)
- over 25°: 0.5 m/s (extreme / scrambling)
Terrain Difficulty Multiplier¶
Further adjusts cost using OSM tags:
sac_scaletrail_visibilitysurface
3. Final Cost Assignment¶
Each edge receives a cost value in seconds (used directly by the A* algorithm).
Additional attributes stored for filtering and debugging:
slopeterrain_factorascent/descentattributes (used in the assigning of costs to edges)
Key Files¶
Cumbria-Elevation-File.tif– Source DEM rasterPathfinding/unpopulated_igraph.pkl– Input graphPathfinding/elevation_populated_igraph.pkl– Output enriched graph
Design Decisions¶
Why Naismith's Rule?¶
- It is a well-established hiking-specific model that balances distance and elevation.
- Our version improves accuracy by incorporating slope-dependent walking speed and terrain multipliers.
Pre-computation vs Runtime¶
- All elevation work is done once during preprocessing. This keeps routing queries extremely fast.
Accuracy Trade-offs¶
- The pipeline uses a single DEM file. Future improvements could include higher-resolution rasters or dynamic fetching for other regions.
- The DEM file used does not account for the Orkney Isles, as a result of data degradation (mapped to 60° North Latitude and Orkney Isles sit at 58-59° North Latitude)
Future Enhancements¶
- Support for multiple regional DEMs
- Integration of more advanced cost models (e.g. Tobler's Hiking Function)
- Real-time slope-based filtering options in the UI