Open Road Risk
  • Home
  • Start Here
  • Project
    • Project overview
    • Current model status
    • AI-assisted development
  • Literature
    • Literature overview
    • Literature evidence register
    • AI-assisted literature review
    • Literature-pipeline alignment
    • Crash frequency models
    • Exposure and traffic volume
    • Spatial methods and network risk
    • Junctions and conflict structure
    • Severity modelling
    • Validation and metrics
    • Transferability and open data limits
  • Data Sources
    • Overview
    • STATS19 Collisions
    • OS Open Roads
    • AADF Traffic Counts
    • WebTRIS Sensors
    • Network Model GDB
    • OS Terrain 50 (grade)
    • Deprivation (IoD 2025)
  • Methodology
    • Methodology Overview
    • Joining the Datasets
    • Feature Engineering
    • Empirical Bayes Shrinkage
  • Exploratory Data Analysis
    • Collision EDA
    • Collision-Exposure Behaviour
    • Vehicle Mix Analysis
    • Road Curvature
    • Months and Days of Week
    • Traffic Volume EDA
    • OSM Coverage
  • Models
    • Modelling Approach
    • Stage 1a: Traffic Volume
    • Stage 1b: Time-Zone Profiles
    • Stage 2: Collision Risk Model
    • Facility Family Split
    • Model Inventory
  • Investigations
    • Investigations overview
    • KSI atlas diagnostic
    • Staffordshire data quality
    • Temporal descriptors evaluation
    • AADF counted-only filter
    • Rank stability harness
    • Zero-calibration diagnostic
  • Outputs
    • Key figures
    • Top-risk map
    • QGIS GeoPackage (Kaggle)
  • Tools
    • ukgeo — UK Geocoder
  • Future Work

On this page

  • 1 Purpose
  • 2 Method
  • 3 Geometry Quality Gate
  • 4 Seeded Random Road-Section Sample
    • 4.1 Sample Section Plots
  • 5 Start/End Nodes and Geometry Coordinates
  • 6 How the Curvature Code Works
  • 7 Interpretation

Road Curvature from OS Open Roads

Analysis of road curvature features derived from OS Open Roads geometry and their coverage, distributions, and modelling caveats.

1 Purpose

This page turns the curvature research note into a concrete, reproducible inspection of the Open Roads geometry. The aim is not to produce engineering-grade curve radius. It is to check whether the centreline geometry can support a conservative link-level ranking signal for the collision model.

The background argument is:

  • Horizontal curves are a recognised crash-risk factor, especially for roadway-departure crashes.
  • OS Open Roads gives broad coverage and stable enough link geometry for feature engineering, but it is a generalised 1:25,000-scale product.
  • Curvature should therefore be treated as a screening/ranking proxy rather than a survey-grade design measure.
  • The implementation uses a vertex-density gate by road class so sparse geometry is left as missing instead of being silently interpreted as straight.

The full background note is in docs/notes/deep-research-roadcurvature.md in Github.

2 Method

For each road link, the curvature module does the following:

  1. Load OS Open Roads geometry and reproject it to a metre-based CRS if needed.
  2. Normalise the geometry to a single LineString; disjoint MultiLineString geometries keep the longest part.
  3. Count original geometry vertices and calculate vertices_per_km.
  4. Decide which road classes pass the operational geometry-quality gate: median vertices_per_km >= 40 and 25th percentile vertices_per_km >= 20.
  5. Resample eligible links at 15 m spacing.
  6. Calculate absolute turning angle at each interior resampled point.
  7. Store three features: mean_curvature_deg_per_km, max_curvature_deg_per_km, and sinuosity.

mean_curvature_deg_per_km is total absolute turning angle per kilometre of link. It is therefore interpretable as “how much the link turns overall”. max_curvature_deg_per_km is the sharpest local turning-angle density found on the resampled line, capped at 10,000 deg/km to suppress single-vertex artefacts. sinuosity is link_length / straight_line_distance, clipped at 5.0 for near-closed loop-like geometries.

Show code
if not OPENROADS_PATH.exists():
    raise FileNotFoundError(f"Open Roads parquet not found: {OPENROADS_PATH}")

openroads = gpd.read_parquet(OPENROADS_PATH)
print(f"Loaded {len(openroads):,} OS Open Roads links from {OPENROADS_PATH.relative_to(ROOT)}")
print(f"Source CRS: {openroads.crs}")
Loaded 3,941,299 OS Open Roads links from data/processed/shapefiles/openroads.parquet
Source CRS: {"$schema": "https://proj.org/schemas/v0.7/projjson.schema.json", "type": "GeographicCRS", "name": "WGS 84", "datum_ensemble": {"name": "World Geodetic System 1984 ensemble", "members": [{"name": "World Geodetic System 1984 (Transit)"}, {"name": "World Geodetic System 1984 (G730)"}, {"name": "World Geodetic System 1984 (G873)"}, {"name": "World Geodetic System 1984 (G1150)"}, {"name": "World Geodetic System 1984 (G1674)"}, {"name": "World Geodetic System 1984 (G1762)"}, {"name": "World Geodetic System 1984 (G2139)"}, {"name": "World Geodetic System 1984 (G2296)"}], "ellipsoid": {"name": "WGS 84", "semi_major_axis": 6378137, "inverse_flattening": 298.257223563}, "accuracy": "2.0", "id": {"authority": "EPSG", "code": 6326}}, "coordinate_system": {"subtype": "ellipsoidal", "axis": [{"name": "Geodetic latitude", "abbreviation": "Lat", "direction": "north", "unit": "degree"}, {"name": "Geodetic longitude", "abbreviation": "Lon", "direction": "east", "unit": "degree"}]}, "scope": "Horizontal component of 3D system.", "area": "World.", "bbox": {"south_latitude": -90, "west_longitude": -180, "north_latitude": 90, "east_longitude": 180}, "id": {"authority": "EPSG", "code": 4326}}
Show code
gdf = openroads.copy()
gdf["geometry"] = gdf.geometry.apply(normalise_linestring)
gdf = gdf.loc[gdf.geometry.notna()].copy()

if gdf.crs is None:
    raise ValueError("Input CRS is missing; curvature needs a metric CRS.")

units = (
    getattr(gdf.crs.axis_info[0], "unit_name", "").lower()
    if gdf.crs.axis_info
    else ""
)
if "metre" not in units and "meter" not in units:
    gdf = gdf.to_crs(27700)

gdf["calc_length_m"] = gdf.geometry.length
gdf = gdf.loc[gdf["calc_length_m"] > 0].copy()
gdf["vertex_count"] = gdf.geometry.apply(vertex_count)
gdf["vertices_per_km"] = gdf["vertex_count"] / (gdf["calc_length_m"] / 1000)

print(f"Metric CRS used for curvature: {gdf.crs}")
print(f"Usable non-empty LineString links: {len(gdf):,}")
Metric CRS used for curvature: EPSG:27700
Usable non-empty LineString links: 3,941,299

3 Geometry Quality Gate

The gate is deliberately operational. It is not an OS-published standard; it is a guardrail for using 15 m resampling on already-generalised Open Roads centreline geometry. Classes that fail the gate should keep curvature as NaN so sparse linework does not become a false zero-curvature signal.

Show code
vertex_summary = (
    gdf.groupby("road_classification", dropna=False)["vertices_per_km"]
    .describe()
    .sort_index()
)

valid_classes = vertex_summary.index[
    (vertex_summary["50%"] >= MEDIAN_VERTICES_PER_KM_MIN)
    & (vertex_summary["25%"] >= P25_VERTICES_PER_KM_MIN)
].tolist()

strategy = (
    "all_classes"
    if set(valid_classes) == set(vertex_summary.index.tolist())
    else "gated_by_road_classification"
)

gate_table = vertex_summary.reset_index().rename(
    columns={
        "road_classification": "road_class",
        "50%": "median_vertices_per_km",
        "25%": "p25_vertices_per_km",
        "75%": "p75_vertices_per_km",
    }
)
gate_table["passes_gate"] = gate_table["road_class"].isin(valid_classes)
show_cols = [
    "road_class",
    "count",
    "mean",
    "p25_vertices_per_km",
    "median_vertices_per_km",
    "p75_vertices_per_km",
    "passes_gate",
]
gate_table[show_cols].round(2)
road_class count mean p25_vertices_per_km median_vertices_per_km p75_vertices_per_km passes_gate
0 A Road 291101.0 142.54 30.05 64.24 127.34 True
1 B Road 164052.0 95.80 26.40 53.72 101.94 True
2 Classified Unnumbered 351667.0 77.52 21.76 43.81 87.47 True
3 Motorway 7166.0 134.93 15.89 24.66 55.31 False
4 Not Classified 399549.0 81.05 40.95 62.75 94.04 True
5 Unclassified 1846477.0 83.26 40.65 62.85 95.65 True
6 Unknown 881287.0 76.64 35.81 59.74 91.78 True

Original geometry vertex density by road class. Dashed lines show the p25 and median gate thresholds.

4 Seeded Random Road-Section Sample

The table and plots below use a reproducible random sample from the actual OS Open Roads parquet. The sample is restricted to links with at least three vertices and length between 30 m and 2 km, so every plotted section has enough geometry to inspect. Curvature is calculated for every sampled section for diagnostic visibility; the passes_class_gate column shows whether production code would persist those values or leave them missing.

Show code
sample_pool = gdf.loc[
    (gdf["vertex_count"] >= 3)
    & (gdf["calc_length_m"].between(30, 2000))
].copy()

sample_links = sample_pool.sample(
    n=min(N_SAMPLE, len(sample_pool)),
    random_state=RANDOM_SEED,
).copy()

feature_rows = []
for idx, row in sample_links.iterrows():
    features = turning_angle_features(row.geometry, spacing_m=SPACING_M)
    feature_rows.append(
        {
            "link_id": row["link_id"],
            MEAN_CURVATURE_COL: features[MEAN_CURVATURE_COL],
            MAX_CURVATURE_COL: features[MAX_CURVATURE_COL],
            SINUOSITY_COL: features[SINUOSITY_COL],
            "passes_class_gate": row["road_classification"] in valid_classes,
        }
    )

sample_features = pd.DataFrame(feature_rows)
sample_links = sample_links.merge(sample_features, on="link_id", how="left")

print(
    f"Seed {RANDOM_SEED} selected {len(sample_links)} links "
    f"from {len(sample_pool):,} eligible road sections."
)
Seed 20260421 selected 8 links from 3,391,571 eligible road sections.
link_id road_classification form_of_way road_name start_node end_node calc_length_m vertex_count vertices_per_km passes_class_gate mean_curvature_deg_per_km max_curvature_deg_per_km sinuosity
5 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 Not Classified Single Carriageway 16395831-A331-46AE-8FFC-A80E89E497C2 D0F4BB14-76EB-4E38-A8C7-C2C115ED9801 232.291 11 47.354 True 803.210 3941.233 1.173
1 825D9ED2-7526-4442-A0D0-DDCD48F59511 Unclassified Single Carriageway Earlswood Mead E48D83CD-9F28-4BBE-93D8-A1DD7C640840 CAC9EECF-FA62-418C-90C1-23D07E161842 45.272 7 154.619 True 492.043 698.015 1.006
4 1D8CA972-B63E-4996-B797-EAD49098CA5F Unknown Single Carriageway 76A4E582-021C-4432-9B3B-45E79341DC50 06253596-8534-4A17-AA61-835AC862DDEF 145.468 6 41.246 True 188.332 2104.861 1.008
0 4836B5F5-3817-455D-AE04-696B7A3C8EC0 Unknown Single Carriageway 958150E3-6575-463D-A35D-E25D7C32AE48 DF38DEA7-2A04-464A-A93B-3B47E27B3DD9 87.093 12 137.784 True 153.392 422.252 1.004
6 21C77B86-B861-402D-99FB-A1CE354832FC Unclassified Single Carriageway King Street BB228E16-A6A9-4750-8926-C0DBEE6C0C6C 76431C25-5454-497F-AC36-DACA7CE957B2 56.797 5 88.033 True 84.350 194.481 1.001
7 109E36A5-9B33-4051-A6D9-2863A0859F78 Unknown Single Carriageway 1929D3C2-402D-44E0-9DAA-165F47DBB829 63DA130B-A097-4AF3-83D8-3C06DC13D7D1 54.527 3 55.019 True 0.322 0.956 1.000
2 89625069-1805-4CF2-BAFC-400E110885F7 B Road Single Carriageway Hawthorne Road 3D651486-478F-41D7-9595-FCAD6AD09DD2 42DDF2E1-99B6-4996-9080-4BD8E6422C3B 65.229 3 45.992 True 0.058 0.207 1.000
3 59F54B64-D3C6-43A5-B499-825976199365 Unclassified Single Carriageway Firwood Avenue EA3FBD63-601D-4776-B5CD-D0A4D2EDB83D B5709FEC-A5FE-4CDA-9247-908D492652B5 48.291 3 62.124 True 0.001 0.002 1.000

4.1 Sample Section Plots

Black lines are the original OS Open Roads link geometry. Blue points are the 15 m resampled points used for turning-angle calculation. Red points are the start and end nodes.

Seeded random sample of Open Roads links with original geometry and 15 m resampled points.

5 Start/End Nodes and Geometry Coordinates

This table exposes the node-level geometry used by the plots. Coordinates are in the metric CRS used for curvature calculation, currently British National Grid if the source parquet is WGS84.

link_id node_role node_id x_m y_m
0 4836B5F5-3817-455D-AE04-696B7A3C8EC0 start 958150E3-6575-463D-A35D-E25D7C32AE48 445413.313 382665.753
1 4836B5F5-3817-455D-AE04-696B7A3C8EC0 end DF38DEA7-2A04-464A-A93B-3B47E27B3DD9 445336.794 382624.858
2 825D9ED2-7526-4442-A0D0-DDCD48F59511 start E48D83CD-9F28-4BBE-93D8-A1DD7C640840 422014.707 432596.705
3 825D9ED2-7526-4442-A0D0-DDCD48F59511 end CAC9EECF-FA62-418C-90C1-23D07E161842 422015.707 432551.705
4 89625069-1805-4CF2-BAFC-400E110885F7 start 3D651486-478F-41D7-9595-FCAD6AD09DD2 333712.501 397573.378
5 89625069-1805-4CF2-BAFC-400E110885F7 end 42DDF2E1-99B6-4996-9080-4BD8E6422C3B 333765.090 397534.788
6 59F54B64-D3C6-43A5-B499-825976199365 start EA3FBD63-601D-4776-B5CD-D0A4D2EDB83D 378273.002 394467.205
7 59F54B64-D3C6-43A5-B499-825976199365 end B5709FEC-A5FE-4CDA-9247-908D492652B5 378273.122 394515.495
8 1D8CA972-B63E-4996-B797-EAD49098CA5F start 76A4E582-021C-4432-9B3B-45E79341DC50 317597.481 174345.671
9 1D8CA972-B63E-4996-B797-EAD49098CA5F end 06253596-8534-4A17-AA61-835AC862DDEF 317561.011 174485.373
10 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 start 16395831-A331-46AE-8FFC-A80E89E497C2 539586.196 236287.567
11 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 end D0F4BB14-76EB-4E38-A8C7-C2C115ED9801 539648.756 236099.694
12 21C77B86-B861-402D-99FB-A1CE354832FC start BB228E16-A6A9-4750-8926-C0DBEE6C0C6C 428016.604 418210.107
13 21C77B86-B861-402D-99FB-A1CE354832FC end 76431C25-5454-497F-AC36-DACA7CE957B2 427962.734 418227.965
14 109E36A5-9B33-4051-A6D9-2863A0859F78 start 1929D3C2-402D-44E0-9DAA-165F47DBB829 273321.745 798462.429
15 109E36A5-9B33-4051-A6D9-2863A0859F78 end 63DA130B-A097-4AF3-83D8-3C06DC13D7D1 273276.207 798432.439

The next table lists the first few original geometry vertices per sampled road section. It is intentionally compact: enough to show the actual coordinate sequence, without printing every point for long links.

link_id vertex_ix x_m y_m
0 4836B5F5-3817-455D-AE04-696B7A3C8EC0 0 445413.313 382665.753
1 4836B5F5-3817-455D-AE04-696B7A3C8EC0 1 445408.033 382663.873
2 4836B5F5-3817-455D-AE04-696B7A3C8EC0 2 445403.003 382662.083
3 4836B5F5-3817-455D-AE04-696B7A3C8EC0 3 445392.693 382658.402
4 4836B5F5-3817-455D-AE04-696B7A3C8EC0 4 445377.983 382649.471
5 4836B5F5-3817-455D-AE04-696B7A3C8EC0 5 445367.203 382642.920
6 825D9ED2-7526-4442-A0D0-DDCD48F59511 0 422014.707 432596.705
7 825D9ED2-7526-4442-A0D0-DDCD48F59511 1 422014.207 432590.705
8 825D9ED2-7526-4442-A0D0-DDCD48F59511 2 422013.707 432584.705
9 825D9ED2-7526-4442-A0D0-DDCD48F59511 3 422015.127 432574.905
10 825D9ED2-7526-4442-A0D0-DDCD48F59511 4 422016.547 432565.095
11 825D9ED2-7526-4442-A0D0-DDCD48F59511 5 422016.127 432558.405
12 89625069-1805-4CF2-BAFC-400E110885F7 0 333712.501 397573.378
13 89625069-1805-4CF2-BAFC-400E110885F7 1 333738.800 397554.078
14 89625069-1805-4CF2-BAFC-400E110885F7 2 333765.090 397534.788
15 59F54B64-D3C6-43A5-B499-825976199365 0 378273.002 394467.205
16 59F54B64-D3C6-43A5-B499-825976199365 1 378273.062 394491.355
17 59F54B64-D3C6-43A5-B499-825976199365 2 378273.122 394515.495
18 1D8CA972-B63E-4996-B797-EAD49098CA5F 0 317597.481 174345.671
19 1D8CA972-B63E-4996-B797-EAD49098CA5F 1 317591.531 174365.931
20 1D8CA972-B63E-4996-B797-EAD49098CA5F 2 317585.571 174386.182
21 1D8CA972-B63E-4996-B797-EAD49098CA5F 3 317570.791 174435.642
22 1D8CA972-B63E-4996-B797-EAD49098CA5F 4 317559.071 174474.893
23 1D8CA972-B63E-4996-B797-EAD49098CA5F 5 317561.011 174485.373
24 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 0 539586.196 236287.567
25 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 1 539601.096 236278.237
26 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 2 539604.076 236276.367
27 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 3 539616.646 236268.497
28 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 4 539645.565 236232.726
29 98CFE5EE-E5DD-4A53-9ED2-311BEF2B7A71 5 539656.665 236213.426
30 21C77B86-B861-402D-99FB-A1CE354832FC 0 428016.604 418210.107
31 21C77B86-B861-402D-99FB-A1CE354832FC 1 427998.664 418216.606
32 21C77B86-B861-402D-99FB-A1CE354832FC 2 427980.714 418223.106
33 21C77B86-B861-402D-99FB-A1CE354832FC 3 427971.724 418225.536
34 21C77B86-B861-402D-99FB-A1CE354832FC 4 427962.734 418227.965
35 109E36A5-9B33-4051-A6D9-2863A0859F78 0 273321.745 798462.429
36 109E36A5-9B33-4051-A6D9-2863A0859F78 1 273298.976 798447.439
37 109E36A5-9B33-4051-A6D9-2863A0859F78 2 273276.207 798432.439

6 How the Curvature Code Works

The production module lives at src/road_risk/features/road_curvature.py

The key pieces are:

  • normalise_linestring() handles empty geometry, LineString, and MultiLineString cases before feature calculation.
  • ensure_metric_crs() converts longitude/latitude geometry to EPSG:27700 so spacing and length calculations are in metres.
  • resample_linestring() interpolates points every 15 m and keeps the link end point, so short residual segments are still represented.
  • turning_angle_features() computes angle changes between consecutive resampled segments, converts those into degrees per kilometre, and returns: mean_curvature_deg_per_km, max_curvature_deg_per_km, and sinuosity.
  • main() runs the vertex-density gate by road_classification, computes features only for passing classes, writes the columns to data/features/network_features.parquet, and writes QA CSV summaries.

The deliberate modelling choice is missingness over false certainty. If a road class fails the vertex-density gate, its curvature features stay NaN rather than being filled with zero. That preserves the distinction between “this link is straight in usable geometry” and “the source geometry is too sparse to support curvature”.

7 Interpretation

For modelling, the expected useful signal is relative rather than absolute: links with more turning per kilometre should rank above straighter links. The numbers should not be read as design-speed radius or engineering inventory values. That limitation is acceptable for a link-level risk model as long as the feature is documented, quality-gated, and evaluated against held-out collision outcomes before being promoted into the main model feature lists.

Open Road Risk

 

Built with Quarto