Draw a map of the districts of Budapest using the Overpass API of OpenStreetMap and Python

Mor Kapronczay
May 28, 2019 · 6 min read
Image for post
Image for post
A map of Budapest. Source: https://hebstreits.com/product/budapest-hungary-downtown-vector-map/
Image for post
Image for post
The relation of the 1st district of Budapest. https://www.openstreetmap.org/relation/221984#map=15/47.4969/19.0375

OSM structures

Access OSM objects automatically

Overpass query for I. kerület in Budapest.

Create a polygon of nodes

Image for post
Image for post
We aim to have something like this at the end. Source: https://100ujgyulekezet.blog.hu/2013/05/29/budapest_xxiv_20_01_resz_a_xxiv_kerulet_helye
Image for post
Image for post
Convex hulls are not fit for the task…
Image for post
Image for post
How concavity messes with the “always add the closest” approach

My solution

Image for post
Image for post
The resulting borders of the districts of Budapest. https://github.com/morkapronczay/osm_bp_districts/blob/master/base_layer_bp.png

Takeaways

Starschema Blog

Data contains intelligence that can change the world — we…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store