Rebuilding geometry assembly from the ground up with ohsome-planet 1.3.1

We are releasing version 1.3.1 of ohsome-planet under the codename "Baarle-Hertog". This tool is designed to facilitate the transformation of raw OpenStreetMap (OSM) history data into the GeoParquet format, making it more accessible for spatial data analysis.

What ohsome-planet does

The ohsome-planet tool can be used to transform OSM (history) PBF files into Parquet format with native GEO support, to turn an OSM changeset file (osm.bz2) into a PostgreSQL database table, and to keep both datasets up to date by ingesting OSM planet replication files.

ohsome-planet creates the actual OSM element geometries for nodes, ways and relations. It enriches each element with changeset data such as hashtags, the OSM editor used, or the username. It’s also possible to add country ISO codes to each element by providing a boundary dataset.

The output of ohsome-planet can be used to perform a wide range of geospatial analyses with tools such as DuckDB, Python GeoPandas or QGIS. It’s also possible to display the data directly on a map and explore it.

A reworked geometry assembler

This release presents a complete rework of our approach to assemble geometries for complex mutlipolygon relations. Our new approach tackles two challenges at the same time. First, processing performance was a bottleneck for relations with a very high number of members. As a consequence we had to limit geometry building to relations with a fixed member count, e.g. below 600. Although most relations in OSM have fewer members, there are still enough common cases, such as country boundaries and lakes, that we weren’t able generate in previous versions. Second, the correct handling of invalid geometries and edge cases made processing even slower.

With our new geometry assembler, we can process the global OSM planet history file about 10x faster than before. You will notice this speed-up effect also for smaller regional extracts. On a Lenovo ThinkPad P14s Gen 5 with Intel® Core™ Ultra 7 165H × 22 and 64GB RAM transforming Germany latest pbf into Parquet took just 27 minutes.

Baarle-Hertog

Baarle-Hertog [1] is an interesting test case for our new geometry assembling approach. The municipality belongs to Belgium and represents a unique arrangement of exclaves fully surrounded by the municipality Baarle-Nassau [2] which happens to be part of the Netherlands.

The OSM community has precisely captured the outcome of medieval treaties, agreements, land-swaps which today depicts an administrative boundary at level 8. The relation/53137 is special because of its multiple inner rings and self-touching outer rings. Given this complexity, it is no surprise that the latest edit of the relation as of today was conducted to „fix boundary relations“ [3].

We are happy that ohsome-planet can handle these and other interesting OSM relations properly. So please don’t stop mapping them in OSM.

The entire source code for this project is hosted on GitHub.