Ptolemy: OSM Dataset
A map of Europe's heritage places, extracted from OpenStreetMap and baked into fast map tiles
- Client
- Ptolemy
- Year
- 2022
- Before
AI - Subject
- GIS
- Result
- European heritage places dataset from OpenStreetMap, vector tilesets and Mapbox Tiling Service recipes
What I did
Ptolemy needed a map of every heritage place in Europe: ruins, castles, churches, museums, monuments, theatres and more. No such dataset existed, so I built one from OpenStreetMap, then baked it into vector tiles so the map stays fast on the web.
Building the dataset
I used Imposm to import OpenStreetMap data into a PostGIS database, with a custom tag mapping that picks out anything tagged as historic, heritage, archaeological, a museum, a castle, a monastery, a memorial and so on. Lines and areas came in as well as points, while plain buildings and land use were filtered out.
OpenStreetMap tags are messy, so SQL scripts sorted every place into a clear type (archaeological, structure, building, religious, military and so on) and an era, from the Stone Age to modern times. Each place also got a score for how important it is, based on its type, whether it has a name and an era, a Wikipedia link or UNESCO status. That score later decides which places show at which zoom level on the map.
Cleaning up took a few more steps:
- Removing empty shapes and places with no name.
- Tagging each place with its country and whether it is in a city.
- Testing on small areas first, like Milan, northern Italy and the Peloponnese, before running all of Europe.
The result was one table of heritage places, ready to be combined with other sources.
Baking it into tiles
Sending every place to a phone at once would be far too slow, so I turned the table into vector tiles with the Mapbox Tiling Service.
A tileset recipe is a short config file that says which places go into which layer, and from which zoom level. I made two versions:
- A basic one with three layers: UNESCO World Heritage sites, visible from far out; other named places from zoom 6; and every place, named or not, when you zoom in close.
- A category one, with a layer per type (archaeological, museums, theatres, religious, structures, areas and others), so each could be styled and hold on its own in the map.
A custom importance score system does the real work here. At each zoom level, the tiling recipe kept only the most important place within a set distance, so the map never gets crowded and the big sites always win. Zoom in and the smaller places appear.
Getting the data there is a short pipeline: the PostGIS table is exported to GeoJSON, uploaded to Mapbox as a tileset source, and then the tilesets are created and published. Tiles only carry what the map needs, like the name, type, era and score. The full details are loaded when someone opens a specific place page.
