All articles
TutorialBy , Bozmaps 12 min read

Auditing a city's cycle network with Mapillary and open source GIS

MapillaryOpenStreetMapPythonQGISActive travelAPI
Map of King Edward Park, Nottingham, with the park boundary, sports areas, walking route, entrances, toilets, bins and benches

Every council in the country can tell you how many kilometres of cycle route it has on paper. Far fewer can tell you what those routes actually look like at street level, when anyone last checked, or which sections quietly stopped being usable. Street-level imagery closes that gap, and with Mapillary it can be done on an entirely open stack for the cost of your own time.

This piece walks through the workflow we use at Bozmaps to audit a cycle network from a desk: pull the network from OpenStreetMap, sweep Mapillary for street-level evidence, join the two, and produce a ranked list of segments worth surveying. We ran it live over Nottingham in August 2026 while writing this, and the numbers below are the real output of that run, not an illustration. OpenStreetMap and Mapillary change every day, so a run today will give slightly different numbers: the results table near the end puts our August figures beside a rerun of the same code on 10 November 2026.

Why street-level imagery earns its place

Cycle infrastructure is unusually badly served by conventional data. Aerial imagery cannot see under a tree canopy, cannot read a give-way marking, and cannot tell you whether a bollard has been replaced by a pile of rubble. Council asset registers are typically organised around maintenance contracts rather than around routes. OpenStreetMap has excellent geometry, but the attributes that actually decide whether someone will ride a route, surface, lighting, width, and barriers, are patchily tagged.

Street-level imagery sits exactly in that gap. It is captured at eye height, it is timestamped, and, in Mapillary's case, it is run through computer vision that extracts discrete objects: lane markings, traffic signs, bike racks, cyclist signals. That gives you two separable things, and keeping them separate matters more than anything else in this workflow:

  • Coverage. Has anyone photographed this place, and how long ago?
  • Detections. Did the vision pipeline find cycling-related objects in those photos?

Conflating the two is the single most common way to produce a confidently wrong map. A traffic-free canal towpath will have no painted bicycle symbols no matter how well photographed it is. We will come back to this.

The open source stack

Nothing here needs a licence, and nothing needs a credit card. The whole pipeline runs on tools that are free to use and free to inspect.

LayerToolRole
Base networkOpenStreetMap via Overpass APICycle route geometry and tags
Street-level imageryMapillary API v4Photos, sequences, CV detections
ProcessingPython, Shapely, GeoPandasSpatial joins, scoring, sampling
StoragePostGIS or GeoPackagePersist the joined result
Desktop GISQGISInspection, cartography, survey packs
Web deliveryMapLibre GL JS, MapillaryJSInteractive map plus imagery viewer
Field capturemapillary_toolsPush new imagery back to the commons

The one thing worth being deliberate about is licensing. OpenStreetMap is ODbL, so derived databases you publish carry share-alike obligations. Mapillary imagery is contributed under CC BY-SA, and the API terms sit on top of that. For internal analysis this rarely bites, but check before you ship a derived dataset to a client, and attribute both.

Getting an API key

Mapillary's v4 API needs a client token. Register an application at mapillary.com/dashboard/developers, and you will get a token in the form MLY|APP_ID|SECRET. There are two surfaces you will use:

  • Graph API at graph.mapillary.com, authenticated with an Authorization: OAuth MLY|... header. Mapillary's documentation splits it into the Entity API (look up one image or map feature by its id) and the Search API (search /images and /map_features by bounding box). This workflow uses the Search API.
  • Tile API at tiles.mapillary.com, authenticated with an ?access_token= query parameter. This serves vector tiles for coverage lines, which is what you want on a web map or as a QGIS layer.
The constraint that shapes everything
Mapillary documents that a bounding box search on /images or /map_features must be smaller than 0.01 degrees square, and a single response returns at most 2,000 records. At Nottingham's latitude a 0.01 degree cell is about 1.1 km north to south and 0.67 km east to west, so anything bigger than a neighbourhood has to be tiled into a grid of small requests. Larger boxes sometimes work and sometimes return a server error, so stay under the documented limit. Build that grid helper first, because every later step depends on it.

Step 1: pull the cycle network from OpenStreetMap

Cycle infrastructure is tagged in OSM three different ways, and if you only query one of them you will miss most of the network. Standalone tracks use highway=cycleway. On-carriageway lanes are tagged on the parent road with cycleway, cycleway:left or cycleway:right. Shared use paths appear as footways or paths with bicycle=designated. Catch all three.

overpass ql
[out:json][timeout:180];
(
  way["highway"="cycleway"](52.90,-1.24,53.00,-1.10);
  way["highway"~"path|footway|track"]["bicycle"~"designated|yes"](52.90,-1.24,53.00,-1.10);
  way["cycleway"~"lane|track|opposite_lane|share_busway"](52.90,-1.24,53.00,-1.10);
  way["cycleway:left"~"lane|track"](52.90,-1.24,53.00,-1.10);
  way["cycleway:right"~"lane|track"](52.90,-1.24,53.00,-1.10);
);
out geom;

Save the query as a text file and post it to the Overpass API. The elements list that comes back is the osm_ways list the join in Step 3 loops over; each way carries its tags and a geometry list of lat/lon points.

python
import json, urllib.parse, urllib.request

QUERY = open("cycle_network.overpassql").read()   # the query above
req = urllib.request.Request(
    "https://overpass-api.de/api/interpreter",
    data=urllib.parse.urlencode({"data": QUERY}).encode(),
    headers={"User-Agent": "cycle-audit (you@example.com)"},
)
osm_ways = json.load(urllib.request.urlopen(req, timeout=200))["elements"]

Over the Nottingham bounding box that returns 2,877 ways totalling 259.1 km. Broken down, 1,378 are shared paths, 1,066 are standalone cycleways, and 433 are on-road lanes. Already the attribute gap is visible: 1,386 of those ways carry no lit tag at all, and 279 have no surface tag. Nearly half the ways have no recorded answer to "is it lit", which for a commuting route through a British winter is close to the only question that matters.

Two tagging gaps worth closing
The query above is exactly what we ran, but it misses lanes recorded on the road as cycleway:both: on 10 November 2026 that was 21 ways (3.1 km) inside this box. Add way["cycleway:both"~"lane|track"](52.90,-1.24,53.00,-1.10); to the list to catch them. Overpass regular expressions also match part of a value, so lane matches shared_lane, which is a painted bicycle symbol on a shared road rather than a lane (18 ways, 1.0 km here). Decide whether you want those counted as lanes.

Step 2: sweep Mapillary for cycling evidence

Now query the /map_features endpoint for the object classes that indicate cycling infrastructure. The three that carry the most signal are the painted bicycle symbol, cyclist-specific traffic signals, and bike racks. Because of the bounding box cap, the area is tiled into a grid of 0.008 degree cells and fetched concurrently.

python
import json, urllib.request, itertools
from concurrent.futures import ThreadPoolExecutor

TOKEN = "MLY|YOUR_APP_ID|YOUR_SECRET"
S, W, N, E = 52.90, -1.24, 53.00, -1.10
STEP = 0.008  # stay under the 0.01 degree cap
VALUES = ",".join([
    "marking--discrete--symbol--bicycle",
    "object--traffic-light--cyclists",
    "object--bike-rack",
])

def cells():
    lat = S
    while lat < N:
        lon = W
        while lon < E:
            yield (lon, lat, min(lon + STEP, E), min(lat + STEP, N))
            lon += STEP
        lat += STEP

def fetch(cell):
    w, s, e, n = cell
    url = (
        "https://graph.mapillary.com/map_features"
        f"?bbox={w:.4f},{s:.4f},{e:.4f},{n:.4f}"
        f"&object_values={VALUES}"
        "&fields=id,object_value,geometry,first_seen_at,last_seen_at&limit=2000"
    )
    req = urllib.request.Request(url, headers={"Authorization": "OAuth " + TOKEN})
    for _ in range(3):                      # the tile grid will produce transient failures
        try:
            return json.load(urllib.request.urlopen(req, timeout=60)).get("data", [])
        except Exception:
            pass
    return []

with ThreadPoolExecutor(max_workers=8) as ex:
    results = list(ex.map(fetch, cells()))

features = {f["id"]: f for f in itertools.chain.from_iterable(results)}  # dedupe by id across cells
print(len(features), "cycling features")

Across 234 grid cells covering Nottingham this returns 356 distinct cycling features: 265 painted bicycle symbols, 88 bike racks, and just 3 cyclist traffic signals. The last_seen_at field is the useful one. Sorted by year, 89 features were last seen in 2026 and 18 in 2025, while 97 were last seen in 2020 and never since. That is a freshness map of the city's imagery, for free, before any joining has happened.

Wildcards save a lot of requests
object_values accepts wildcards. regulatory--* pulls every regulatory sign class in one call, which is far cheaper than enumerating them. Use the same trick for warning--* when you are looking at junction safety rather than cycling specifically.

Step 3: join the two and score each segment

The join is a proximity test: for each OSM way, is there a Mapillary cycling detection within 20 metres of its geometry? A spatial index keeps this fast. Testing every node of a long way is wasteful, so the loop below tests at most about 40 of its nodes.

python
import math
from collections import defaultdict

GRID = 0.0005  # roughly 55 m
index = defaultdict(list)
for f in features.values():
    lon, lat = f["geometry"]["coordinates"]
    index[(int(lat / GRID), int(lon / GRID))].append((lon, lat, f))

def metres_per_degree(lat):
    return 111320.0, 111320.0 * math.cos(math.radians(lat))

def nearby(lon, lat, radius=20.0):
    my, mx = metres_per_degree(lat)
    span = int(radius / (GRID * 111320)) + 1
    hits = []
    for dy in range(-span, span + 1):
        for dx in range(-span, span + 1):
            for flon, flat, f in index.get((int(lat / GRID) + dy, int(lon / GRID) + dx), ()):
                if math.hypot((flat - lat) * my, (flon - lon) * mx) <= radius:
                    hits.append(f)
    return hits

corroborated, unverified = [], []
for way in osm_ways:
    geom = way["geometry"]
    stride = max(1, len(geom) // 40)
    hits = {f["id"]: f for node in geom[::stride] for f in nearby(node["lon"], node["lat"])}
    (corroborated if hits else unverified).append({"way": way, "hits": list(hits.values())})

The result over Nottingham is stark. Only 172 ways, 15.8 km, or 6.1% of the network by length, sit within 20 metres of a Mapillary cycling detection. And of those 172, 108 ways covering 11.6 km are corroborated only by evidence last seen in 2020 or earlier.

One limit of this shortcut: it tests nodes, not the straight runs between them, so a detection beside the middle of a long, straight segment can be missed. For a strict audit, buffer each way by 20 metres in British National Grid (EPSG:27700) and use a spatial join instead. On our November rerun that found 190 corroborated ways (17.7 km) where node sampling found 185 (16.6 km).

Step 4: separate "no detection" from "no imagery"

This is the step most desk audits skip, and it is the one that decides whether the output is trustworthy. A segment with no cycling detection could mean nobody has ever photographed it, or it could mean it has been photographed thoroughly and simply has no paint on it. Those two findings lead to completely different actions, so measure them apart.

Take a random sample of the un-corroborated segments and probe the /images endpoint around the middle node of each way with a tight box. The code adds 0.00035 degrees each way, which at Nottingham's latitude is about 39 metres north and south but only about 23 metres east and west, so the probe is a box of roughly 78 by 47 metres.

python
import random
random.seed(7)

def has_imagery(way, box=0.00035):
    node = way["geometry"][len(way["geometry"]) // 2]
    url = (
        "https://graph.mapillary.com/images"
        f"?bbox={node['lon']-box:.5f},{node['lat']-box:.5f},"
        f"{node['lon']+box:.5f},{node['lat']+box:.5f}"
        "&fields=id,captured_at&limit=50"
    )
    req = urllib.request.Request(url, headers={"Authorization": "OAuth " + TOKEN})
    return json.load(urllib.request.urlopen(req, timeout=60)).get("data", [])

sample = random.sample([u["way"] for u in unverified], 120)
probed = [has_imagery(w) for w in sample]

Of 120 sampled segments, 76 (63%) had no Mapillary imagery in that box at all, and 44 (37%) had imagery but no cycling detection. Among the 44 that were photographed, only 16 had anything captured in 2025 or 2026. The rest were last seen in 2021 or earlier, with 2020 by far the largest single year.

That sample reframes the headline. It is not that 94% of Nottingham's cycle network is undocumented. In our August sample, roughly two thirds of the un-corroborated segments had no Mapillary imagery at the probe point, and most of the rest was photographed before the current decade's schemes were built.

Treat a sample of 120 with care: its margin of error is about 9 percentage points either way. When we reran the probe on 10 November 2026 for all 2,712 un-corroborated segments, 47% had no imagery in the box (49% counting only imagery captured by 26 August 2026). Probing every segment took about 2,700 requests and a few minutes, so do that rather than sampling.

What the Nottingham run produced

MeasureAugust 2026 runRerun, 10 November 2026
OSM cycle-related ways in the AOI2,877 ways, 259.1 km2,897 ways, 259.7 km
Ways with no lit tag1,386 (48%)1,389 (48%)
Mapillary cycling features found356 (265 markings, 88 racks, 3 signals)361 (267 markings, 91 racks, 3 signals)
Network corroborated by a detection within 20 m172 ways, 15.8 km, 6.1%185 ways, 16.6 km, 6.4%
Corroborated only by evidence from 2020 or earlier108 ways, 11.6 km110 ways, 11.6 km
Sampled gap segments with no imagery in the probe box63% of n=12050% of n=120 (47% of all 2,712)
Un-corroborated and missing surface or lit tag1,306 ways, 103.9 km1,307 ways, 104.0 km

The rerun used the same Mapillary code and the same OpenStreetMap filters, applied to the Geofabrik Nottinghamshire extract of 8 November 2026 because the public Overpass server did not answer from our machine that day. The small differences come from edits to OpenStreetMap and new Mapillary imagery since August, and the sample row also moves because a different set of segments is drawn.

That last row is the deliverable. 103.9 km of Nottingham's cycle network has no Mapillary cycling detection within 20 metres and is missing at least one of the two attributes that determine whether the route is usable after dark or on a road bike. Step 4 showed that some of it is photographed but simply has no paint to detect, so treat it as a list to check rather than a list of unphotographed routes. Sorted by length, the longest candidates are unnamed traffic-free paths and cycleways over a kilometre long, exactly the kind of green corridor that is easy to build and easy to forget about.

Step 5: get it into QGIS and onto a web map

Export the joined result as GeoJSON and load it into QGIS alongside Mapillary's own coverage tiles. In the Browser panel, right-click Vector Tiles and choose New Generic Connection…. Paste the URL below as the Source URL and set the Max. Zoom Level to 14, because Mapillary's coverage tiles stop at zoom 14. You get sequence lines (and, at zoom 14, image points) under your analysis that you can inspect with the Identify Features tool.

text
https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=MLY|YOUR_APP_ID|YOUR_SECRET

For a shareable version, MapLibre GL JS renders the same tiles, and MapillaryJS renders the photo itself. Wiring them together takes one extra layer and one event handler: draw the image points, read the id off the clicked point and hand it to the viewer.

javascript
map.addSource("mapillary", {
  type: "vector",
  tiles: ["https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=" + TOKEN],
  minzoom: 6,
  maxzoom: 14,
});

map.addLayer({
  id: "mapillary-sequence",
  type: "line",
  source: "mapillary",
  "source-layer": "sequence",
  paint: { "line-color": "rgb(53,175,109)", "line-width": 2, "line-opacity": 0.6 },
});

// image points are in the "image" source-layer, at z14 only
map.addLayer({
  id: "mapillary-image",
  type: "circle",
  source: "mapillary",
  "source-layer": "image",
  minzoom: 14,
  paint: { "circle-radius": 3, "circle-color": "rgb(53,175,109)" },
});

map.on("click", "mapillary-image", (e) => {
  viewer.moveTo(e.features[0].properties.id);
});

One catch: some newer Mapillary image ids are larger than a JavaScript number can hold exactly (260 of the 22,603 image points in one central Nottingham tile on 10 November 2026), and a rounded id is rejected. If the viewer cannot find an image, look it up through the Graph API by the point's sequence_id instead.

The result is a review tool rather than a static map. A planner can click any flagged segment, see whatever imagery does exist, and decide in seconds whether it needs a site visit or whether the existing photo already answers the question.

Step 6: close the loop by capturing the gaps

The output of the audit is a survey list, and the survey is a bike ride. A camera that writes its GPS track into the video, on a bar mount and ridden along the ranked segments, produces geotagged imagery that goes back to Mapillary with the official command-line tool, mapillary_tools. Sampling video needs FFmpeg installed.

bash
pip install mapillary_tools

# once: sign in and save a local profile under a name of your choice
mapillary_tools authenticate --user_name my_profile

# sample a ride video into geotagged frames every 3 m, then upload
mapillary_tools video_process_and_upload ./rides/2026-08-26-beeston-canal.mp4 ./processed \
  --video_sample_distance 3 \
  --user_name my_profile

The video and the folder for the sampled frames are given in that order, without option names (checked with mapillary_tools 0.15.0, November 2026). Sampling by distance rather than by time is the detail that matters on a bike. Time-based sampling gives you a dense clump of near-identical frames every time you stop at a light, and gaps on the fast descents. Three metres is the tool's default and suits cycle paths.

Re-run the audit once Mapillary has processed the uploads. The coverage probe in Step 4 now finds fresh imagery on those segments, and any painted symbols, racks or cyclist signals on them appear as detections. A traffic-free path with no paint stays un-corroborated however well it is photographed, which is exactly why coverage is measured separately. Either way the network's evidence base improves permanently, for everyone, and the next audit starts from a better baseline.

What this workflow does not tell you

Being straight about the limits is what makes the output usable in a planning context.

  • Detections are not an audit of quality. A bicycle symbol proves paint existed when the photo was taken. It says nothing about lane width, surface condition, or whether the lane is permanently occupied by parked cars.
  • Coverage is volunteer-driven and therefore biased. Mapillary coverage clusters on roads that people drive and on routes that enthusiasts ride. Absence of imagery correlates with quiet residential and traffic-free routes, which skews any naive "worst first" ranking.
  • OSM tagging conventions vary locally. The query above covers the common UK tags once you add cycleway:both as described in Step 1. Other countries lean on different tags, and a mapper community with different habits will change what the base layer looks like.
  • A 20 metre join radius is a choice, not a fact. Tighten it and dual carriageways stop borrowing each other's detections. Loosen it and you gain recall on GPS-noisy imagery. Test both and state which you used.

Running it in your own area

The only thing specific to Nottingham is the bounding box: one line of the Python (S, W, N, E) and the five bounding boxes in the Overpass query. Swap it for your own, keep the grid step under 0.01 degrees, and the rest of the pipeline is unchanged. On a city-sized area the Mapillary sweep is quick (234 requests took 29 seconds in our November rerun), and even probing every gap segment stays well inside Mapillary's published limits of 10,000 Search API requests per minute per app and 50,000 tile requests per day.

The wider point is that this is not really a cycling workflow. Replace the three cycling object classes with object--street-light and you have a lighting asset audit. Replace them with regulatory--* and you have a signage compliance check. Replace them with object--catch-basin and you have a drainage inventory. The pattern of joining an open network to timestamped street-level evidence, then separating "no evidence" from "no coverage", generalises to most linear asset problems in the public realm.

Working on something similar?
We build these pipelines for councils, consultancies, and active travel and transport teams, from one-off audits to automated monitoring that re-runs on a schedule. If you have a network to assess, get in touch and we will tell you honestly whether the open data is good enough for what you need.

Ready-to-run QGIS models from £1

Flood, NDVI, land surface temperature, wildfire, landslide and more, each with a PDF guide and a licence.