5 unstable releases

0.3.3 May 23, 2023
0.3.2 Apr 10, 2023
0.2.0 Apr 1, 2023
0.1.0 Mar 27, 2023

#216 in Geospatial

Download history 9/week @ 2023-06-03 25/week @ 2023-06-10 52/week @ 2023-06-17 55/week @ 2023-06-24 63/week @ 2023-07-01 99/week @ 2023-07-08 41/week @ 2023-07-15 125/week @ 2023-07-22 47/week @ 2023-07-29 98/week @ 2023-08-05 29/week @ 2023-08-12 56/week @ 2023-08-19 68/week @ 2023-08-26 47/week @ 2023-09-02 32/week @ 2023-09-09 34/week @ 2023-09-16

200 downloads per month


2.5K SLoC

Java 1.5K SLoC // 0.2% comments Rust 892 SLoC // 0.0% comments C++ 243 SLoC // 0.3% comments Shell 2 SLoC


Read and write the PBF format for Open Street Map (OSM).



There are two steps to reading the PBF format: parsing and decoding. Parsing builds fileblocks out of the raw data. Decoding converts fileblocks into the OSM elements that they contain.


Similarly, there are two steps to writing the PBF format: encoding and serialization. Encoding converts OSM elements into fileblocks. This crate does not support encoding yet. Serialization flattens fileblocks into raw data.


This crate is written with async I/O for use with tokio.


The code is serial in nature but it's possible to parallelize encoding/decoding since fileblocks are independent in PBF.

Read parallelization example:

  1. Call get_osm_pbf_locations to get a stream of fileblock locations
  2. Call parse_osm_pbf_at_location for each location independently
  3. Process blocks as desired

Write parallelization example:

  1. Split your blocks into chunks
  2. Call write_osm_pbf for each chunk independently with an in-memory vector as the writer
  3. As each call completes, write them to their final destination (i.e. a file)


There is a feature for each supported compression algorithm:

Name Default Feature Supported

Lz4 support is not available yet. Bzip2 has been deprecated for years so it is not supported.

There isn't any fine-grained control over encoding but feel free to file an issue if you are interested.


~208K SLoC