Georeferenced Addresses in Brandenburg (Germany) as background layer for the OpenStreetMap editor JOSM
The basic geo data of the state of Brandenburg (in Germany) are available as Open Data. This includes the Georeferenced Addresses (house number coordinates). Since April 2020 it is possible to use this data in OpenStreetMap.
This project compares the official addresses to those found in OpenStreetMap. It provides the addresses as background layer that can be used while editing OpenStreetMap’s map data and highlights the addresses that might be missing.
See
for background and usage information and a preview of the data.
The official address data cannot be downloaded automatically. Please go to
https://geobroker.geobasis-bb.de/ and download the data set “Georeferenzierte
Adresse” in GeoPackage format. Don’t be discourage by the “order” process. The
data is free and Open Data. Extract the download and provide the data as file
data/geoadr.gpkg
.
Run ./01_download.sh
. This will download the latest OpenStreetMap dump for
Brandenburg.
The data is merged in a PostGIS database. This script creates a new working database.
Import the official addresses into the database using ogr2ogr
.
Import the OpenStreetMap addresses into the same database using osmium
and
osm2pgsql
.
Match the addresses from the different data sets by executing analyze_addresses.sql.
Addresses are matched by comparing only street and house number (and not city
or postal code). House numbers with suffixes such as 1 A
, 1 B
are
standardized by removing whitespace and turning them to lower case.
As result the official addresses are annotated whether or not they could be matched in OSM.
The script also computes aggregations for lower zoom levels. The address points are mapped onto a hexagonal grid using the H3 indexing system. It counts for each hexagon how many unmatched addresses there are.
Usually one could color the hexagons by value later when they are visualized using MapLibre JS. But JOSM doesn’t support this syntax, so the classes for the colors have to be precomputed instead. The style then uses a fixed mapping from class ID to color.
Finally the script also provides the functions that are used to export the data in tiles in Mapbox Vector Tiles (MVT) format.
Export the data in MVT format. This uses
tippecanoe. It calls the MVT
export functions defined in analyze_addresses.sql
and writes them to files.
Script to upload the website Markdown files and the exported MVT tiles to branch gh_pages. A GitHub action renders the website into static HTML using Jekyll. Finally everything is served as static files from https://hfs.github.io/brandenburg-addresses/.
The easiest way to get all required dependencies and run the pipeline is to use
podman. It should be readily available as package on
recent Linux distributions. If you have podman
installed you can run
podman play kube kube.yaml
This will first build the two images defined in brandenburg_addresses/ and brandenburg_addresses_postgres/ which contain all the required dependencies.
It starts the two as containers and runs run.sh, which just calls the scripts 01 to 06 (except the final upload).
The generated output data can be found in tiles/
.
You need to install these dependencies:
- curl, wget, pv, mmv
- osm2pgsql, osmium-tool
- PostgreSQL server and client, PostGIS
- ogr2ogr (package gdal-bin)
- tippecanoe
Also you need PostgreSQL extensions H3 and
kmeans which probably aren’t available as
packages. You can install the PostgreSQL extension manager pgxnclient
and
then run
pgxn install h3
pgxn install kmeans
to install them.
You need a PostgreSQL superuser – typically it’s called postgres
. Set a
password for it. Edit env.sh
and insert the password there.
Then you can run the processing pipeline using
./run.sh
style.json contains the Mapbox GL JS style which defines the look
of the map data in JOSM. mapbox-gl-style.json is a
variant of the same style, and the only difference is the attribution
which
uses HTML links to point to the source data.
If you want to edit the style you can load it in the Maputnik Style Editor.
JOSM supports only a subset of the Mapbox Style specification. You can test the
results locally by adding MVT imagery source in JOSM which uses a file://
URL
to point to your local modified copy of the style.