Benchmarking OSM parsing tools#
TL;DR
As of October 2026, pyrosm is the fastest and most memory-efficient tool in this benchmark for reading buildings and road networks from PBF files, on every area from the Helsinki region up to all of Spain (1.5 GB). On all of Finland, for example, it reads the buildings in under 10 s, against 41.5 s for QuackOSM and 100 s for osmextract, on a laptop with 24 GB of RAM. pyrosm also crops large .osm.pbf files about as fast as the C++-based osmium-tool: 15.9 s against 16.7 s on one thread, and 4.4 s against 3.7 s on eight threads in its fast mode, with about a tenth of osmium-tool’s peak memory.
pyrosm is a Python library for reading OpenStreetMap data from PBF files into GeoPandas GeoDataFrames. PBF (Protocolbuffer Binary Format) is the compressed binary format in which OpenStreetMap distributes its data. Most of pyrosm is written in Cython and C. It has two engines: the in-memory engine parses the whole file into memory, and the out-of-core engine reads the file in one streaming pass, keeps intermediate data on disk and decodes the data blocks on several threads at once. This keeps its peak memory low and lets it read files larger than the computer’s memory.
Here, we compare pyrosm with six other widely used OpenStreetMap tools on the same tasks:
Tool |
What it is |
Reads a local |
|---|---|---|
Cython OSM→GeoPandas reader (in-memory + out-of-core engines) |
yes |
|
OSM→GeoPandas/NetworkX via the Overpass API |
no (downloads from Overpass) |
|
DuckDB-based OSM→GeoParquet/GeoPandas reader |
yes |
|
Python bindings to libosmium (streaming C++ reader/writer) |
yes |
|
C++ command-line tool (libosmium); filter + export to GeoJSON, read with GeoPandas |
yes |
|
Java command-line tool for manipulating PBF data |
yes |
|
R package: downloads and reads OSM via GDAL into |
yes |
We benchmark three tasks:
Parse buildings into a GeoDataFrame on areas from a single neighbourhood up to a whole country, measuring time and peak memory.
Parse the road network (
highway=*ways) in the same way.Crop a large PBF (all of Finland) down to the Helsinki region and write the result to a new
.osm.pbffile.
How the comparison is kept fair#
Same input. Every local-file tool reads the same PBF file; OSMnx downloads the same area from the Overpass API.
Same selection. Each tool is given the same OSM tag filter (
building/highway).Same output. Tools disagree on whether a tag filter should also return tagged nodes (e.g.
highway=bus_stop), so we count only polygons for buildings and lines for roads, and show the counts side by side.Isolated runs. Each parse and each crop runs in its own process, and
run_monitored.pyrecords its time and peak memory. Each read is repeated several times and we report the median; for pyrosm’s road networks and its geometry-and-key buildings, the fastest of the medians of three runs on one day. Caches are cleared before every read, so each one really parses the file, and the notebook pauses after every run so that the heat of one run does not slow down the next.Checked crops. Each cropped file is read back and its buildings counted, so a crop that lost data would show up.
Not every tool can do every task. OSMnx downloads from the Overpass API and cannot read or crop local files, so it is not in the cropping task. Osmosis does not build GeoDataFrames, so it only crops. osmextract (R) reads but does not crop; its results come from the companion
osmextract_benchmark_scaling.ipynbnotebook. osmium-tool parses by exporting GeoJSON, which GeoPandas then reads. pydriosm has no tag filter at read time, so it cannot do a like-for-like extraction and is left out.
Cores differ by tool. The parsing runs use each tool’s defaults, so some tools run on one core and others on several. pyrosm’s in-memory engine and pyosmium’s Python loop run on one core, while QuackOSM, osmium-tool and pyrosm’s out-of-core engine use several. With
workers="auto", pyrosm reads files under about 20 MB on one thread, files of about 20 to 70 MB, such as the Helsinki region extract (65 MB), on up to 4 threads, and larger files on the number of CPU cores minus two (8 threads on this laptop).
Hardware#
The benchmarks were run on a MacBook Air (M5) with 24 GB of RAM, 10 CPU cores and an SSD, running macOS Tahoe 26.6.
Data#
Buildings are parsed across a ladder of areas of increasing size:
Kamppi neighbourhood (clipped from the Helsinki extract),
Helsinki Region (~65 MB, BBBike),
New York City (~153 MB, BBBike),
Paris (~243 MB, BBBike),
Finland (~771 MB, Geofabrik), and
Spain (~1,491 MB, Geofabrik).
South America (~4,139 MB, Geofabrik), used only in the head-to-head test of pyrosm and QuackOSM.
The in-memory engine is run up to Finland and skipped on Spain, where it would exceed the available memory. OSMnx is run on Kamppi and the Helsinki region only. Cropping uses all of Finland (approx. 770 MB from Geofabrik) as the large input that gets cropped down to the Helsinki region.
Results#
This section sums up the main results; the sections further below give every number and the code behind it. All runs were made on one laptop with nothing else running, so read the rankings as indicative rather than exact.
The tools return nearly the same features. From the Helsinki region up, the counts of building polygons and road lines agree across the tools to within 2 % (about 187,000 buildings and 305,000 road lines in the Helsinki region).
Parsing buildings#
From the Helsinki region up, pyrosm’s out-of-core engine is the fastest reader of buildings and uses the least memory. It reads New York City and Paris in 4.5–5.3 s, where QuackOSM takes 22–24 s and osmextract 26–28 s. On Finland it takes under 10 s (QuackOSM 41.5 s, osmextract 100 s), and on Spain 24 s (66 s and 181 s). QuackOSM with tag columns and osmium-tool need far more memory as the files grow: QuackOSM runs out of memory on Spain, and osmium-tool on Finland. On the smallest area, Kamppi, osmextract and pyosmium finish first.
pyrosm’s in-memory engine is as fast as the out-of-core engine on the small areas, but slower on the large ones (Finland 40.5 s against 9.8 s), and it needs much more memory (17.4 GB on Finland against 5.1 GB). Compared with pyrosm 0.20.0, the out-of-core engine now reads buildings nearly three times as fast (Finland 9.8 s instead of 29 s).


Parsing the road network#
Road networks show the same picture. From the Helsinki region up, pyrosm’s out-of-core engine is again the fastest and uses the least memory. It reads New York City and Paris in about 3 s and Finland in 8.3 s, where osmextract takes 7–8 s and 35 s. On Spain it takes 22 s, against 101 s for QuackOSM and 121 s for osmextract. OSMnx could not download the road networks from the public Overpass API during this benchmark (see Task 1).


pyrosm vs QuackOSM on the same workload#
In the charts above each tool uses its own defaults, which do not return the same tag columns. Here pyrosm and QuackOSM do exactly the same work: both read only the geometry and the building tag, on every area from Kamppi up to all of South America (4.1 GB). pyrosm is faster at every size: 4.6 to 7.5 times as fast from the Helsinki region to Finland (Finland 9.0 s against 41.7 s), nearly three times as fast on Spain (22.9 s against 66.1 s) and more than four times as fast on South America (78 s against 342 s). It also uses less memory, for example 6.7 GB against 19.8 GB on Spain.

Cropping a country down to a region#
pyrosm and osmium-tool are by far the fastest croppers. On one thread, pyrosm crops all of Finland down to the Helsinki region in 15.9 s, slightly faster than osmium-tool (16.7 s). On eight threads, pyrosm’s fast mode takes 4.4 s, close to osmium-tool’s 3.7 s. The fast mode skips re-packing the data, so its file is larger (85 MB instead of 61 MB); the compact mode takes 6.4 s on eight threads. pyrosm needs less than 0.5 GB of memory in every mode, against about 4 GB for osmium-tool. Osmosis takes 189 s and pyosmium about 230 s. Compared with pyrosm 0.21.0, the eight-thread fast crop now takes less than half the time (11.7 s before), and compared with pyrosm 0.23.0 the eight-thread compact crop takes 6.4 s instead of 11.6 s.

Where pyrosm fits#
From the Helsinki region up to Spain, pyrosm reads buildings and road networks faster than the other tools tested, with the lowest peak memory. Only on the smallest extract (Kamppi) do osmextract and pyosmium finish first. In cropping, pyrosm is slightly faster than osmium-tool on one thread and close to it on eight, with a tenth of the memory. And it does all of this from one Python object: OSM(fp) reads buildings, roads, POIs and other layers into GeoDataFrames in one line of code (e.g. OSM(fp).get_buildings()), exports networks to igraph, NetworkX or Pandarm, and crops the file to a new PBF.
Running the tests#
The rest of this page documents how the benchmarks were run. We have tried to make the comparison as fair as possible, but we are not experts in all of these tools, and some of them may run faster with other settings. If you see a way to make the comparison fairer, please open an issue on GitHub.
Installation#
The Python tools, osmium-tool, the Java runtime for Osmosis and the notebook’s plotting and
data-frame packages are installed into one environment from
ci/benchmarks.yaml, which pins
the versions benchmarked here; Osmosis and osmextract are then installed as shown below. pyrosm is installed from its PyPI wheel, and all of its results were measured with pyrosm 0.25.0, on 25 October 2026. The other tools were measured earlier in October 2026, with the versions pinned in the file. OSMnx,
QuackOSM, pyosmium and osmium-tool come from conda-forge; Osmosis (a Java tool) and osmextract
(an R package) are installed separately.
mamba env create -f ci/benchmarks.yaml
mamba activate pyrosm-benchmarks
# Osmosis 0.49.2: download it from https://github.com/openstreetmap/osmosis/releases and put
# the `osmosis` launcher on your PATH (the environment brings the Java runtime).
# osmextract (run by the companion osmextract_benchmark_scaling.ipynb) from CRAN, and the
# Jupyter kernel for R:
R -e 'remotes::install_version("osmextract", version = "0.6.0", repos = "https://cloud.r-project.org")'
R -e 'IRkernel::installspec()'
Running#
Run the notebooks from a copy of the docs/benchmarks folder outside any synced folder (such as
OneDrive or Dropbox): the downloaded data, the tools’ temporary files and caches, and the
results are written into that folder (data/, tmp/, the result CSV files and figures/).
After every run the notebook pauses for half as long as the run took (at least 2 seconds, at
most 5 minutes), so that the heat of one run does not slow down the next. Every run is logged to
benchmark.log in that folder, with its start and end, its time and memory so far every 30
seconds, and the pause after it. Follow the runs in a terminal with tail -f benchmark.log.
cp -R docs/benchmarks ~/pyrosm-benchmarks
cd ~/pyrosm-benchmarks
rm osm_parsing_results.csv osmcrop_results.csv osmextract_scaling_results.csv # the published results
caffeinate -i jupyter lab # caffeinate keeps the Mac awake during the long runs
Run benchmarks_scaling.ipynb first, then osmextract_benchmark_scaling.ipynb (R), and then benchmarks_scaling.ipynb once more, either in JupyterLab or from a terminal with
jupyter nbconvert --to notebook --execute --inplace --ExecutePreprocessor.timeout=-1 <notebook>.
Each result is written to osm_parsing_results.csv (the crops to osmcrop_results.csv, and
osmextract’s results to osmextract_scaling_results.csv) as soon as it is measured, and a run that finds a result already there prints it instead of measuring it
again. The second run of benchmarks_scaling.ipynb therefore repeats no measurements: after two
short setup steps (clipping Kamppi and reading the Helsinki region’s extent for OSMnx) it draws
the tables and charts, now with osmextract’s results. A run that was stopped continues where it
left off. To measure a tool again, delete its rows from the results file; the copy above starts
without the published results, so that every result is measured.
If a tool is missing, its cells below are skipped automatically (they are guarded by an availability check), so the rest of the notebook still runs end to end.
Setup: imports, tool detection and helpers#
Many code cells are hidden from the website to make the report easier to read, but you can open them to see how the benchmarks are run.
OMP: Warning #179: Function Can't set size of /tmp file failed:
Detected tools:
pyrosm 0.25.0
osmnx 2.1.1
quackosm 0.19.0
pyosmium 4.3.1
osmosis 0.49.2
osmium-tool 1.19.1
Data#
Buildings and Roads are parsed across a ladder of areas of increasing size, so the timings show how each tool scales with input: Kamppi (a neighbourhood clipped out of the Helsinki extract), the Helsinki Region, New York City, Paris, Finland and Spain. pyrosm is measured with both engines. The in-memory engine runs up to Finland and is skipped on Spain, and OSMnx runs on Kamppi and the Helsinki region only.
Cropping uses all of Finland (about 770 MB from Geofabrik) as the large input that gets cropped down to the Helsinki region.
Everything is downloaded automatically by pyrosm.get_data(...). The Finland and Spain
downloads are large and may take a while the first time.
Region PBF : data/Helsinki.osm.pbf (64.9 MB)
Finland PBF: data/finland-latest.osm.pbf (771.0 MB)
Buildings area ladder:
Kamppi data/kamppi.osm.pbf ( 6.2 MB)
Helsinki region data/Helsinki.osm.pbf ( 64.9 MB)
New York City data/newyorkcity.osm.pbf ( 153.2 MB)
Paris data/Paris.osm.pbf ( 242.5 MB)
Finland data/finland-latest.osm.pbf ( 771.0 MB)
Spain data/spain-latest.osm.pbf ( 1490.5 MB)
South America data/south-america-latest.osm.pbf ( 4139.1 MB)
Task 1 — Parse buildings into a GeoDataFrame: time and memory across area sizes#
Every tool selects the building-tagged features and reads them into a GeoDataFrame (osmextract into an R sf data frame), repeated across the area ladder (Kamppi → Spain). Following the practice of the osm-python-readers-benchmark, each parse runs in its own process while run_monitored.py samples the peak memory of its process tree (the physical footprint on macOS) alongside the time (with a per-size timeout). Also, a crash or out-of-memory kill is recorded. pyrosm’s out-of-core engine (engine="out_of_core", workers="auto") can read files that no longer fit in RAM, because it streams the data through temporary files on disk. Its result cache is cleared before each read, so that every measurement includes the parse. It runs the full ladder, as QuackOSM (DuckDB) does. The in-memory engine (engine="in_memory") is run up to Finland and skipped on Spain, where it is expected to exceed the 24 GB of RAM. pyosmium (a streaming reader) and osmium-tool (a command-line tool; here it exports GeoJSON, which is then read with GeoPandas) read the local files too: pyosmium is run on the four smaller areas (Kamppi → Paris) and osmium-tool up to Finland. OSMnx downloads from the public Overpass API rather than reading the local file, so its time includes the download and the Overpass server’s work and is not directly comparable to the local-file readers; its peak memory covers only the local OSMnx process. The public Overpass API has performance issues under heavy load, which shows in the results: during this benchmark (October 2026) OSMnx fetched the buildings of Kamppi (66 s) and the Helsinki region (34 s), but the Overpass server refused its requests for the road networks of these two areas, and earlier requests for both buildings and roads on New York City and Paris timed out. To keep the load on the public Overpass service reasonable, OSMnx is run once on each of the two smallest areas only. In the previous version of this benchmark (June 2026, with older versions of the tools), OSMnx fetched the buildings of Kamppi in 4 s and of the Helsinki region in 46 s, and the road networks of all four areas: Kamppi in 26 s, the Helsinki region in 93 s, New York City in 248 s and Paris in 159 s.
Each area runs in its own cell below, so you can run and inspect them one at a time; re-running an area’s cell measures only the tools whose results are not stored yet (delete a row from osm_parsing_results.csv to measure it again).
# Kamppi (smallest area) - 10 iterations each tool
run_buildings_for_area(AREA["Kamppi"])
Kamppi (6 MB, up to 10x, timeout 120s):
pyrosm (in-memory) 0.80 s 125 MB 684 polys
pyrosm (out-of-core) 0.81 s 127 MB 684 polys
quackosm (with columns) 10.35 s 291 MB 682 polys
quackosm (no columns) 9.99 s 291 MB 682 polys
pyosmium 0.58 s 90 MB 682 polys
osmium-tool 0.68 s 664 MB 638 polys
osmnx 65.64 s 231 MB 685 polys
# Helsinki region - 10 iterations each tool
run_buildings_for_area(AREA["Helsinki region"])
Helsinki region (65 MB, up to 10x, timeout 300s):
pyrosm (in-memory) 2.45 s 1008 MB 187,421 polys
pyrosm (out-of-core) 2.06 s 597 MB 187,421 polys
quackosm (with columns) 18.48 s 4597 MB 187,452 polys
quackosm (no columns) 12.71 s 1055 MB 187,452 polys
pyosmium 13.79 s 3143 MB 187,452 polys
osmium-tool 10.47 s 2969 MB 186,971 polys
osmnx 34.16 s 4087 MB 187,952 polys
# New York City - 5 iterations except pyosmium/osmium-tool run only once (timeout at 15 minutes)
run_buildings_for_area(AREA["New York City"])
New York City (153 MB, up to 5x, timeout 900s):
pyrosm (in-memory) 10.70 s 5573 MB 1,602,597 polys
pyrosm (out-of-core) 4.53 s 2286 MB 1,602,597 polys
quackosm (with columns) 77.53 s 24012 MB 1,602,652 polys
quackosm (no columns) 21.75 s 3376 MB 1,602,652 polys
pyosmium timeout 18388 MB peak
osmium-tool 102.94 s 30633 MB 1,600,058 polys
# Paris - pyosmium/osmium-tool run only once (timeout at 20 minutes)
run_buildings_for_area(AREA["Paris"])
Paris (242 MB, up to 3x, timeout 1500s):
pyrosm (in-memory) 13.92 s 6663 MB 1,888,463 polys
pyrosm (out-of-core) 5.29 s 2944 MB 1,888,463 polys
quackosm (with columns) 120.88 s 35740 MB 1,888,696 polys
quackosm (no columns) 24.09 s 5587 MB 1,888,696 polys
pyosmium timeout 26515 MB peak
osmium-tool 146.34 s 44424 MB 1,873,130 polys
# Finland (country; in-memory engine might run out of memory)
run_buildings_for_area(AREA["Finland"])
Finland (771 MB, up to 3x, timeout 3600s):
pyrosm (in-memory) 40.48 s 17372 MB 4,379,257 polys
pyrosm (out-of-core) 9.80 s 5145 MB 4,379,257 polys
quackosm (with columns) 438.96 s 103274 MB 4,379,400 polys
quackosm (no columns) 41.46 s 5958 MB 4,379,400 polys
osmium-tool OOM/crash (exit -9) 121574 MB peak
# Spain (large country; in-memory engine expected to run out of memory)
run_buildings_for_area(AREA["Spain"])
Spain (1491 MB, up to 3x, timeout 3600s):
pyrosm (out-of-core) 24.10 s 7913 MB 5,731,551 polys
quackosm (with columns) OOM/crash (exit -9) 147705 MB peak
quackosm (no columns) 66.20 s 19742 MB 5,735,125 polys
Task 2 — Parse the road network into a GeoDataFrame: time and memory across area sizes#
The same comparison as buildings, for the road network: every tool extracts highway=* ways as
lines (LineString/MultiLineString) and we record time and peak memory across the area
ladder, each parse in its own isolated subprocess. pyrosm uses get_data_by_custom_criteria({"highway": True}) with both engines. The skips are mostly the same as in the buildings task: in-memory pyrosm, osmium-tool and pyosmium are not run on Spain (they would run out of memory or time out), and OSMnx is run on Kamppi and the Helsinki region only; its road-network requests to the public Overpass API failed during this benchmark (see Task 1). OSMnx returns a simplified routing graph rather than the raw ways, so even a successful request
would give a line count that is not directly comparable. Each area runs in its own cell below; re-running an area’s cell measures only the tools whose road results are not stored yet.
# Kamppi (smallest area)
run_network_for_area(AREA["Kamppi"])
Kamppi (6 MB, up to 10x, timeout 120s):
pyrosm (in-memory) 0.81 s 131 MB 4,795 lines
pyrosm (out-of-core) 0.82 s 135 MB 4,795 lines
quackosm (with columns) 10.96 s 341 MB 4,794 lines
quackosm (no columns) 10.02 s 291 MB 4,794 lines
pyosmium 0.66 s 119 MB 4,854 lines
osmium-tool 0.80 s 1149 MB 4,800 lines
osmnx error (exit 1): requests.exceptions.ConnectionError: HTTPSConnectionPool(host='overpass-api.de', ... er (Caused by NewConnectionError("HTTPSConnection(host='overpass-api.de', port=443): Failed to establish a new connection: [Errno 61] Connection refused")) 224 MB peak
# Helsinki region
run_network_for_area(AREA["Helsinki region"])
Helsinki region (65 MB, up to 10x, timeout 300s):
pyrosm (in-memory) 2.62 s 1079 MB 305,148 lines
pyrosm (out-of-core) 2.17 s 660 MB 305,148 lines
quackosm (with columns) 57.50 s 12153 MB 305,060 lines
quackosm (no columns) 13.01 s 1044 MB 305,060 lines
pyosmium 62.24 s 10144 MB 308,683 lines
osmium-tool 29.98 s 9792 MB 305,327 lines
osmnx error (exit 1): requests.exceptions.ConnectionError: HTTPSConnectionPool(host='overpass-api.de', ... er (Caused by NewConnectionError("HTTPSConnection(host='overpass-api.de', port=443): Failed to establish a new connection: [Errno 61] Connection refused")) 222 MB peak
# New York
run_network_for_area(AREA["New York City"])
New York City (153 MB, up to 5x, timeout 900s):
pyrosm (in-memory) 5.48 s 2834 MB 674,751 lines
pyrosm (out-of-core) 2.84 s 994 MB 674,751 lines
quackosm (with columns) 43.44 s 12255 MB 674,641 lines
quackosm (no columns) 16.19 s 1872 MB 674,641 lines
pyosmium 64.27 s 10693 MB 677,387 lines
osmium-tool 34.86 s 10323 MB 674,870 lines
# Paris
run_network_for_area(AREA["Paris"])
Paris (242 MB, up to 3x, timeout 1500s):
pyrosm (in-memory) 6.04 s 3119 MB 639,431 lines
pyrosm (out-of-core) 3.00 s 995 MB 639,431 lines
quackosm (with columns) 69.02 s 18458 MB 637,311 lines
quackosm (no columns) 17.69 s 1911 MB 637,311 lines
pyosmium 85.87 s 14205 MB 649,388 lines
osmium-tool 44.73 s 13674 MB 639,950 lines
# Finland
run_network_for_area(AREA["Finland"])
Finland (771 MB, up to 3x, timeout 3600s):
pyrosm (in-memory) 25.26 s 14075 MB 2,224,133 lines
pyrosm (out-of-core) 8.25 s 3626 MB 2,224,133 lines
quackosm (with columns) 660.51 s 110100 MB 2,223,189 lines
quackosm (no columns) 35.81 s 15815 MB 2,223,189 lines
pyosmium timeout 57484 MB peak
osmium-tool 357.69 s 102909 MB 2,225,136 lines
# Spain
run_network_for_area(AREA["Spain"])
Spain (1491 MB, up to 3x, timeout 3600s):
pyrosm (out-of-core) 22.33 s 10595 MB 5,812,581 lines
quackosm (with columns) OOM/crash (exit -9) 148696 MB peak
quackosm (no columns) 101.06 s 22058 MB 5,788,516 lines
Head-to-head: pyrosm vs QuackOSM, geometry + key only#
In the comparison above, pyrosm and QuackOSM do not do exactly the same work: QuackOSM either turns every tag into a GeoDataFrame column, which is expensive, or returns no tag columns at all. To compare them on equal footing, both parse only the geometry and the key tag (building) into a GeoDataFrame, with no other tag columns. pyrosm (out-of-core) uses get_data_by_custom_criteria({"building": True}, tags_as_columns=["building"], keep_other_tags=False) and QuackOSM uses tags_filter={"building": True}, keep_all_tags=False. Both read nodes, ways and relations. The cell below runs this across every area and records the rows under their own task (buildings (geometry + key)).
Head-to-head: geometry + 'building' only (pyrosm out-of-core vs quackosm):
Kamppi (6 MB, up to 10x):
pyrosm (out-of-core) 0.82 s 126 MB 684 polys
quackosm 10.35 s 295 MB 682 polys
Helsinki region (65 MB, up to 10x):
pyrosm (out-of-core) 1.77 s 494 MB 187,421 polys
quackosm 13.29 s 1044 MB 187,452 polys
New York City (153 MB, up to 5x):
pyrosm (out-of-core) 3.56 s 1852 MB 1,602,597 polys
quackosm 21.40 s 3374 MB 1,602,652 polys
Paris (242 MB, up to 3x):
pyrosm (out-of-core) 4.53 s 2430 MB 1,888,463 polys
quackosm 24.52 s 5597 MB 1,888,696 polys
Finland (771 MB, up to 3x):
pyrosm (out-of-core) 9.04 s 4140 MB 4,379,257 polys
quackosm 41.70 s 5970 MB 4,379,400 polys
Spain (1491 MB, up to 3x):
pyrosm (out-of-core) 22.86 s 6735 MB 5,731,551 polys
quackosm 66.14 s 19761 MB 5,735,125 polys
South America (4139 MB, up to 1x):
pyrosm (out-of-core) 77.76 s 24174 MB 25,616,024 polys
quackosm 341.80 s 25736 MB 25,618,595 polys
Task 3 — Crop a large PBF to a region and save to disk#
Crop the Finland PBF down to the Helsinki region bounding box and write a new .osm.pbf. All four croppers keep complete ways (ways crossing the box keep all their nodes). Each crop runs in its own process, and its result is then read back and its buildings counted, as a check that no buildings were lost.
OSMnx and QuackOSM are not part of this task: OSMnx does not handle local PBF files, and QuackOSM converts PBF to GeoParquet rather than writing a cropped .osm.pbf.
Here each tool runs on a single thread: pyrosm with workers=1, and pyosmium and osmium-tool with OSMIUM_POOL_THREADS=1. Osmosis is the exception, as its Java pipeline always uses several threads. The next section gives the tools several threads (the number of CPU cores minus two, at most 8) to show how each one scales.
Task 3 - crop Finland to the Helsinki region (buildings = count read back):
pyrosm 15.9 s 427 MB 60.9 MB out 225,570 buildings
pyosmium 234.8 s 882 MB 61.7 MB out 225,570 buildings
osmium-tool 16.7 s 3937 MB 61.7 MB out 225,570 buildings
osmosis 189.4 s 441 MB 61.3 MB out 225,570 buildings
Task 3 with several threads — does parallelism speed up the crop?#
Re-run the Finland → Helsinki crop in parallel, using each tool’s own mechanism:
pyrosm crops on several threads with
to_pbf(..., workers=N), compared atworkers=1andworkers=N, where N is the number of CPU cores minus two, at most 8 (8 on this laptop).pyosmium uses libosmium’s thread pool (
OSMIUM_POOL_THREADS) only to (de)compress the PBF blocks. Its extract loop is single-threaded Python, so it gains little from more threads.osmium-tool uses the same thread pool, but the rest of its extract runs in C++, so it scales the best of the three.
Osmosis has no thread setting for this crop, so it is left out.
Each output is read back and its buildings counted, as in Task 3.
Task 3 in parallel - more workers / threads:
pyrosm, 8 workers (fast-mode) 4.4 s 479 MB 85.3 MB out 225,570 buildings
pyrosm, 8 workers (compact) 6.4 s 478 MB 60.9 MB out 225,570 buildings
pyosmium, 8 threads 228.0 s 923 MB 61.7 MB out 225,570 buildings
osmium-tool, 8 threads 3.7 s 3972 MB 61.7 MB out 225,570 buildings
| run | tool | seconds | peak_mb | out_mb | buildings | status | |
|---|---|---|---|---|---|---|---|
| 0 | pyrosm, 8 workers (fast-mode) | pyrosm | 4.4 | 478.6 | 85.3 | 225570 | ok |
| 1 | pyrosm, 8 workers (compact) | pyrosm | 6.4 | 478.1 | 60.9 | 225570 | ok |
| 2 | pyosmium, 8 threads | pyosmium | 228.0 | 922.8 | 61.7 | 225570 | ok |
| 3 | osmium-tool, 8 threads | osmium-tool | 3.7 | 3972.2 | 61.7 | 225570 | ok |
Collect all the Python tool results and visualise#
# Results were exported incrementally as each tool finished (record_result). Load them back here
# for the tables and charts; re-running this cell picks up whatever has been collected so far.
parsing_df = (pd.read_csv(RESULTS_CSV) if os.path.exists(RESULTS_CSV)
else pd.DataFrame(columns=RESULT_COLUMNS))
Results: tables and visualisations#
# osmextract is an R package; its results come from the companion notebook
# osmextract_benchmark_scaling.ipynb (R kernel), which writes osmextract_scaling_results.csv
# (buildings and the road network across the area ladder, with time + peak memory) next to this
# file. Load it so osmextract appears in the tables and charts.
osmextract_csv = Path("osmextract_scaling_results.csv")
if osmextract_csv.exists():
rows = pd.read_csv(osmextract_csv)
print(f"Loaded {len(rows)} osmextract row(s) from {osmextract_csv}")
parsing_df = pd.concat([parsing_df, rows], ignore_index=True)
else:
print("osmextract_scaling_results.csv not found - run osmextract_benchmark_scaling.ipynb (R).")
Loaded 12 osmextract row(s) from osmextract_scaling_results.csv
parsing_table = parsing_df
print("Parsing tasks (seconds = median wall-clock; features = normalised count):")
display(parsing_table)
#crop_results = False
if crop_results:
# Combine all results together
all_crop_results = crop_results + parallel_crop_results
crop_table = pd.DataFrame(all_crop_results)
print("\nCropping task:")
display(crop_table)
Parsing tasks (seconds = median wall-clock; features = normalised count):
| task | area | tool | seconds | peak_mb | features | status | |
|---|---|---|---|---|---|---|---|
| 0 | buildings | Kamppi | quackosm (with columns) | 10.35 | 290.8 | 682.0 | ok |
| 1 | buildings | Kamppi | quackosm (no columns) | 9.99 | 291.0 | 682.0 | ok |
| 2 | buildings | Kamppi | pyosmium | 0.58 | 90.0 | 682.0 | ok |
| 3 | buildings | Kamppi | osmium-tool | 0.68 | 663.5 | 638.0 | ok |
| 4 | buildings | Helsinki region | quackosm (with columns) | 18.48 | 4597.1 | 187452.0 | ok |
| ... | ... | ... | ... | ... | ... | ... | ... |
| 94 | roads | Helsinki region | osmextract | 3.49 | 717.0 | 305177.0 | ok |
| 95 | roads | New York City | osmextract | 7.31 | 1250.7 | 674850.0 | ok |
| 96 | roads | Paris | osmextract | 8.04 | 1223.5 | 639805.0 | ok |
| 97 | roads | Finland | osmextract | 35.29 | 4234.0 | 2224380.0 | ok |
| 98 | roads | Spain | osmextract | 121.12 | 11203.5 | 5813702.0 | ok |
99 rows × 7 columns
Cropping task:
| run | tool | seconds | peak_mb | out_mb | buildings | status | |
|---|---|---|---|---|---|---|---|
| 0 | pyrosm | pyrosm | 15.9 | 427.3 | 60.9 | 225570 | ok |
| 1 | pyosmium | pyosmium | 234.8 | 882.5 | 61.7 | 225570 | ok |
| 2 | osmium-tool | osmium-tool | 16.7 | 3936.7 | 61.7 | 225570 | ok |
| 3 | osmosis | osmosis | 189.4 | 440.6 | 61.3 | 225570 | ok |
| 4 | pyrosm, 8 workers (fast-mode) | pyrosm | 4.4 | 478.6 | 85.3 | 225570 | ok |
| 5 | pyrosm, 8 workers (compact) | pyrosm | 6.4 | 478.1 | 60.9 | 225570 | ok |
| 6 | pyosmium, 8 threads | pyosmium | 228.0 | 922.8 | 61.7 | 225570 | ok |
| 7 | osmium-tool, 8 threads | osmium-tool | 3.7 | 3972.2 | 61.7 | 225570 | ok |
Area-level visualisations across all tools#
Reading buildings with the same workload — pyrosm vs QuackOSM#
Time and peak memory side by side, one area per row. Each panel keeps its own scale, so the small areas stay readable next to the big ones — lower is better for both.
Time to crop a country-level PBF into a smaller one#