Skip to content

cartoway/osm-pbf-simplify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osm-pbf-simplify

Simplify geometries in OpenStreetMap PBF files using the Osmium Library and the Douglas-Peucker algorithm from libGEOS.

This tool reduces the geometric complexity of OSM data, typically resulting in geometries that use around 20% fewer nodes, while keeping all original nodes in the file, though some become unused.

Nodes at the start or end of ways, or shared by multiple ways, or with tags are always preserved in the simplified version.

Note: The resulting PBF file size usually remains nearly the same.

This simplification is especially useful when you want to reduce geometry precision before processing OSM data with other tools. Like in OSRM to reduce disk and memory usage by about 20%.

Build

mkdir build && cd build
cmake ..
make

Usage

./osm-pbf-simplify input.osm.pbf <EPSG-code> <tolerance> output.osm.pbf
  • EPSG-code — Target projection (e.g., 2154 for Lambert-93).
  • tolerance — Simplification tolerance in projection units (e.g., meters).

It is recommended to select a projection that uses meters or similar units, so the tolerance value is consistent. If unsure, use a suitable UTM zone EPSG code, UTM coordinates are in meters.

The simplification is performed on projected coordinates using the Douglas–Peucker algorithm from libGEOS. A reimplementation that uses Haversine distance (on geographic coordinates) is welcome.

Example

./osm-pbf-simplify andorra-latest.osm.pbf 2154 2 output.osm.pbf

data change, before and after animation

About

Simplify geometries in OpenStreetMap PBF files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published