Skip to content

a-b-street/osm2streets

Repository files navigation

osm2streets

OpenStreetMap (OSM) has many details about streets, but the schema presents many challenges for rendering, routing, and analyzing done at the detail of lanes, especially in the presence of dual carriageways, separated cycletracks and footways, and complex intersections. osm2streets provides a simplified street network schema, a library transforming OSM data into this representation, and tools to render and work with the results.

Getting started

  1. Open StreetExplorer
  2. Select a test area from the left, then click Reimport
  3. Or navigate to anywhere in the world and press Import current view (change the driving side in Settings first)

Features

  • A schema able to represent:

    • Roads leading between two intersections
      • Thickened line-strings
      • A list of lanes from left-to-right, with: type, direction, width
    • Intersections linking roads
      • Polygon areas, with each road polygon intersecting at a perpendicular angle
      • Planned: turning movements and crosswalks
    • Planned: bike boxes / advanced stop lines, pedestrian crossing islands, modal filters
  • Rendering to GeoJSON

    • Individual lane and intersection polygons
    • Lane markings: lines between lanes, schematic display of turn arrows and access restrictions
  • Transformations to simplify complex OSM situations

    • Collapsing "unnecessary" intersections between 2 roads
    • Merging "sausage links" and dual carriageways into a single road
    • Merging "dog-leg" intersections and other short roads into one logical intersection
    • "Snapping" parallel cycletracks and footways to the main road

There are other planned features:

  • routing (score functions can take advantage of knowing how a cycle lane is segregated from the road)
  • isochrone / walkshed calculations
  • map-matching GPS trajectories to routes
  • tracing the area in between roads ("walking around the block")
  • robustly representing user-created edits to the street network model, even when underlying OSM data is updated

Some of these extra features may sound redundant with libraries like osmnx and existing OSM routers. osm2streets will support these features in a way that uses the lane-level detail and consolidated road representation, is compatible with user-made edits to the network, and can be deployed in a variety of environments (native, web, offline without running an external server).

Users

  • StreetExplorer: a web app to interactively import OSM and explore the osm2streets output
  • A/B Street: a collection of projects to design cities friendlier to walking, cycling, and public transit. osm2streets began life here.
  • Bus Spotting: a bus network GTFS viewer, using osm2streets to snap routes to roads
  • MapLibre route snapper plugin: draw line-strings snapped to the road network
  • osm2streets-vector-tileserver: Dynamically generate vector tiles and view with QGIS, Mapbox, etc
  • lane editor to edit OSM tags and see visual results
  • Planned: plugins for iD and JOSM to display streets in detail and visually edit lane tagging

Using osm2streets in your projects

You can use osm2streets today with Leaflet, Mapbox, OpenLayers, or any other web map frameworks. The osm2streets Javascript API can render to GeoJSON.

There are Python bindings, complete with an example notebook.

Since the API isn't stable yet, please get in touch first.

Java bindings are also in progress, with C++ planned.

Architecture

osm2streets architecture

The osm2streets library itself (Rust):

Bindings for other languages:

The StreetExplorer web app (Javascript, CSS using Leaflet):

  • web: the Svelte web app
  • tests: regression tests covering complex OSM input

Contributing

There's many opportunities to help out:

  • writing and improving transformations of street networks
  • adjusting the schema to represent bike boxes, modal filters, lanes that change width, etc
  • designing how to render lane detail
  • integrating the library into your own OSM tool
  • adding test cases for representative situations requiring simplification

Check out the issues.

Further reading