#accessibility #tags #car #node #properties #require

bin+lib osm4routing

Convert OpenStreetMap data into routing friendly CSV

15 releases

new 0.5.9 Dec 1, 2023
0.5.8 Jun 28, 2023
0.5.4 May 23, 2023
0.4.1 Apr 3, 2023
0.1.0 Oct 19, 2016

#23 in Geospatial

Download history 445/week @ 2023-08-10 573/week @ 2023-08-17 369/week @ 2023-08-24 355/week @ 2023-08-31 656/week @ 2023-09-07 434/week @ 2023-09-14 228/week @ 2023-09-21 581/week @ 2023-09-28 621/week @ 2023-10-05 448/week @ 2023-10-12 948/week @ 2023-10-19 511/week @ 2023-10-26 574/week @ 2023-11-02 689/week @ 2023-11-09 1046/week @ 2023-11-16 873/week @ 2023-11-23

3,202 downloads per month
Used in roads-from-nd

MIT license

789 lines


This project is a rewrite in rust from https://github.com/Tristramg/osm4routing

It converts an OpenStreetMap file (in the .pbf format) into a CSV file.


Get a rust distribution with cargo: https://www.rust-lang.org/en-US/downloads.html

Run cargo install osm4routing

You can now use osm4routing <some_osmfile.pbf> to generate the nodes.csv and edges.csv that represent the road network.

If you prefer running the application from the sources, and not installing it, you run

cargo run --release -- <path_to_your_osmfile.pbf>

The identifiers for nodes and edges are from OpenStreetMap.

The id property of an edge is unique, while the osm_id can be duplicated.

Importing in a database

If you prefer having the files in database, you can run the very basic import_postgres.sh script.

It supposes that a database osm4routing exists (otherwise modify it to your needs).

Using as a library

In order to use osm4routing as a library, add osm4routing = "*" in your Cargo.toml file in the [dependencies] section.

Use it:

let (nodes, edges) = osm4routing::read("some_data.osm.pbf")?;

If you wand to reject certain edges based on their tag, use the Reader (it also accepts "*" to reject every value):

let (nodes, edges) = osm4routing::Reader::new().reject("area", "yes").read("some_data.osm.pbf")?;

If you want only specific tags, use required; it accepts "*" if any value is accepted; if multiple conditions are given, it will accept any way that matches at least one of the values.

let (nodes, edges) = osm4routing::Reader::new().require("railway", "rail").read("some_data.osm.pbf")?;

If you need to read some tags, pass them to the reader:

let (nodes, edges) = osm4routing::Reader::new().read_tag("highway").read("some_data.osm.pbf")?;


~144K SLoC