1
1
Fork
You've already forked deleted-map
0
show the last version of the geometry of ways deleted from OpenStreetMap
  • JavaScript 72.8%
  • C 22.1%
  • C++ 2.6%
  • CMake 1.3%
  • Lua 0.6%
  • Other 0.6%
Find a file
2026年03月26日 11:22:16 +01:00
cmake initial commit 2025年08月18日 17:52:13 +02:00
frontend Change name and write content for About page 2026年03月26日 11:22:16 +01:00
martin Add Martin config 2026年03月25日 18:09:38 +01:00
processing Add missing spatial indexes 2026年03月25日 18:06:54 +01:00
src Write timestamp of deletion 2026年03月23日 18:59:40 +01:00
tests Only store the last version of a node prior to the deletion of its way 2026年03月23日 16:10:43 +01:00
tilemaker-config Lower minzoom to 10, reduce too strong simplification 2026年03月26日 09:09:29 +01:00
.gitignore Add .gitignore 2026年03月26日 09:12:10 +01:00
CMakeLists.txt Add unit tests for all indexes 2026年03月17日 17:51:32 +01:00
COPYING Add readme and license 2026年03月17日 19:36:21 +01:00
README.md Add Martin config 2026年03月25日 18:09:38 +01:00

Making deleted OpenStreetMap ways visible again

OpenStreetMap data has become the source for map data for outdoor activities. Hikers and cyclists sometimes use private tracks and paths or ways where they are not welcome. Some land owners or authorities delete those tracks and paths. Many deletions are reverted but some are overseen.

This project aims to provide a visualisation of the geometry of ways which were deleted from OpenStreetMap.

This repository contains the preprocessing toolchain.

Building

Dependencies:

  • C++17 compiler
  • Osmium library
  • CMake
  • Tilemaker >= 3.1.0 (required for generation of vector tiles)

Debian/Ubuntu: apt install build-essential libosmium2-dev cmake

Arch Linux: pacman -S base-devel libosmium cmake

Build:

mkdir build
cd build
cmake ..
make

Run make test in order to run all tests.

How it works

Step 1: Extract and restore deleted ways

deleted_map_preprocessor reads a full history raw OSM data file and creates a raw OSM data file with all ways which were deleted. It adds all nodes used by the last visible version of those ways. If the nodes were modified between the last visible version of the way and the invisible (deleted) version of the way, they will be added with a new fake ID.

deleted_map_preprocessor aims to restore the ways as they were just a moment before they were deleted.

Relations and deleted nodes are not supported.

  • Input format: .osh.pbf (OpenStreetMap raw data in Protocol Buffers but with all versions of all objects)
  • Output format: .osm.pbf (OpenStreetMap raw data in Protocol Buffers), .osm (OpenStreetMap XML, optionally compressed by Bzip2)

In order to save memory, the output file is not sorted. You have to call osmium sort --strategy multipass -o sorted.osm.pbf unsorted.osm.pbf after calling deleted_map_preprocessor.

You can get regional full history dumps from Geofabrik Downloads.

deleted_map_preprocessor -dwr -t 2012年09月15日T00:00:00Z germany-internal.osh.pbf germany-deleted.osm.pbf
osmium sort -s multipass --overwrite -o germany-deleted-sorted.osm.pbf germany-deleted.osm.pbf

Step 2: Produce vector tiles of all deleted ways

Now you can produce a vector tile set out of the .osm.pbf file or use it for any other OSM processing tool.

If you prefer to continue with Tilemaker, you can use the configuration from the tilemaker-config/ directory:

tilemaker --config tilemaker-config/config.json --process tilemaker-config/process.lua --input germany-deleted-sorted.osm.pbf --output germany-deleted.mbtiles

If you want to open the MBTiles file in QGIS or read with any other software using GDAL/OGR, don't forget to set geometry types. You can do this with following SQL script:

sqlite3 germany-deleted.mbtiles < tilemaker-config/patch-tilestats.sql

Step 3: Extract deleted ways without close-by replacements

Many OpenStreetMap ways have been deleted in the past because they were merged with adjacent ways or because they were replaced by other ways at almost the same location. If one wants to find all ways which were deleted without replacements, we have to gid rid of those deleted ways which are in close proximity of existing features. In the following example, we will limit our search onto ways with a highway=* tag.

Import current OpenStreetMap data into a PostgreSQL database (17:49 minutes for DACH):

createdb -E utf8 -O $USER delmap
psql -d delmap -c "CREATE EXTENSION postgis;"
wget https://download.geofabrik.de/europe/dach-latest.osm.pbf
osm2pgsql -d delmap --style processing/generic-osmp2pgsl.lua --output flex dach-latest.osm.pbf

Now create a separate schema deleted in the database and import all reconstructed, deleted ways (5:41 minutes for DACH):

psql -d delmap -c "CREATE schema deleted;"
osm2pgsql --schema deleted -d delmap --output flex --style processing/generic-osm2pgsql.lua dach-deleted-sorted.osm.pbf

Run processing (takes about 7 minutes for DACH region):

psql -d delmap -f processing/find-gone-roads.sql

You can export the database tables into a Geopackage file for debugging purposes:

OGR_SQLITE_SYNCHRONOUS=OFF OGR_SQLITE_JOURNAL=OFF OGR_SQLITE_CACHE=512 ogr2ogr -f GPKG gone_ways.gpkg "PG:dbname=delmap" gone_ways -gt 100000 -nln gone_ways -select old_geometry,osm_id,highway,surface,disused:highway,abandoned:highway,razed:highway,tracktype,trail_visibility,access
OGR_SQLITE_SYNCHRONOUS=OFF OGR_SQLITE_JOURNAL=OFF OGR_SQLITE_CACHE=512 ogr2ogr -f GPKG gone_ways.gpkg "PG:dbname=delmap" gone_ways -gt 10000 -nln gone_sections -select subtracted_geometry,osm_id,highway,surface,disused:highway,abandoned:highway,razed:highway,tracktype,trail_visibility,access -update

Use martin-cp to export the tiles as vectortiles:

martin-cp -c martin/config.yaml --min-zoom 10 --max-zoom 14 --mbtiles-type flat --bbox 5.95,45.81,17.17,55.0992 --encoding gzip --concurrency 4 -o ~/jobs/deleted-map/2026-03/gone_ways.mbtiles -s gone_ways,gone_sections

Performance

Measurements were taken with Debug builds, GCC 13.3, Libosmium 2.20.0, Osmium 1.16.0, AMD Ryzen 5 7600, 64 GB RAM and a Samsung SSD 990 PRO 2TB on Ubuntu Noble.

DACH (Germany + Austria + Switzerland):

  • input: 15 GB .osh.pbf 15 GB .osh.pbf
  • processing: 2:12 min, 3.1 GB RAM
  • sorting: 21 s, 5.9 GB RAM
  • output: 949 MB .osm.pbf

License

The code published in this repository is licensed under GNU Affero General Public License version 3 (AGPLv3).

Alternatives

Overpass Attic queries are the only soultion available for end users without programming skills and are limited to a certain point of time in the past. In addition, public instances of Overpass suffer from systematic overload due to scraping by AI companies, poorly written software (AI slop) etc.