#openstreetmap #osm #topology

app osm-lump-ways

Group OpenStreetMap lines based on graph topology and OSM tags

12 releases (5 breaking)

new 0.6.0 Sep 28, 2023
0.6.0-rc1 Sep 22, 2023
0.5.0 Sep 21, 2023
0.4.0 Aug 17, 2023
0.1.0 Mar 31, 2023

#12 in Geospatial

Download history 4/week @ 2023-06-07 19/week @ 2023-06-14 10/week @ 2023-06-21 41/week @ 2023-06-28 4/week @ 2023-07-05 2/week @ 2023-07-12 18/week @ 2023-07-19 11/week @ 2023-07-26 1/week @ 2023-08-02 14/week @ 2023-08-09 29/week @ 2023-08-16 5/week @ 2023-08-23 1/week @ 2023-08-30 18/week @ 2023-09-06 4/week @ 2023-09-13 81/week @ 2023-09-20

107 downloads per month

MIT/Apache and AGPL-3.0


osm-lump-ways group OSM ways based on topology & shared tags


Answer questions about OSM data like:

  • “What's the longest Main Street?”
  • “How far can I drive on unpaved roads in this region?”
  • “How long is the M1 motorway?”
  • “Are these rivers connected?”
  • “What's the river drainage basins?”


Generate river drainage basins

osm-lump-ways -i path/to/region-latest.osm.pbf -o region-rivers.geojson -f waterway=river

To group based on the river's name:

osm-lump-ways -i path/to/region-latest.osm.pbf -o region-rivers.geojson -f waterway=river -g name

To find long streets and assemble them into connected (Multi)LineStrings:

osm-lump-ways -i path/to/region-latest.osm.pbf -o region-rivers.geojson -f highway -g name


cargo install osm-lump-ways


OSM linear features (eg roads, rivers, walls) are stored as way object. The OSM tagging model often requires one feature to be mapped as many different ways. osm-lump-ways will assemble them all together.

Full Options

Run with --help to see all options.

Examples of usage


This software isn't finished, here's what I'd like to add. Feel free to send a patch.

  • Support outputting GeoJSONSeq instead of one large GeoJSON FeatureCollection
  • The --split-into-way uses Floyd–Warshall algorithm to calculate all pairs shortest path. It's incredibly slow on large numbers of points, e.g. >10k. It also single threaded. This should be replaces with something like multiple runs of Dijkstra's Algorithm to speed it up.
  • All tags need to be specified in advance to join on. Perhaps add something to match all possible tags? (inspired by this q). (“Group by all tags the same” might do it)

External Mentions


Copyright & Licence

Copyright 2023, MIT/Apache2.0. Source code is on Github (osm-lump-ways).

The output data file(s) are a Derived Database of the OpenStreetMap database, and hence under the ODbL 1.0 licence, the same as the OpenStreetMap copyright, and contains data © OpenStreetMap contributors


~744K SLoC