GeoDesk for Python: Analyze & Visualize OpenStreetMap Data

Hi all,

We’re pleased to announce that GeoDesk is now available for Python.
GeoDesk is an open-source toolkit for geographic object libraries, which store OpenStreetMap data in a compact format and allow fast queries.

You may already know about our Java-based toolkit and the GOL tool that we’ve shipped last year. Feedback has been very positive overall, but there has been one recurring theme: What if you needed more complex queries than the GOL tool provides, but weren’t ready (or willing) to build a full-blown Java application?

Our latest release bridges this gap and puts the ability to work with OSM data into the hands of a much larger audience. Python scripts are easy to write (even a complete beginner can learn the basics in an afternoon) and open the door to a vast ecosystem of tools, from mapping to machine learning.

GeoDesk is 100% FOSS, and has minimal hardware requirements. It currently supports Python 3.7 or above, on Windows and Linux (MacOS support is experimental and limited to Catalina 10.15 or later).

To get started, create a GOL from any .osm.pbf file using the GOL tool (download / tutorial). On any reasonably modern machine, this takes less than an hour for the planet, or a few minutes for a country-size extract. (While a GOL is only about 40% larger than the .osm.pbf, you will need available storage for temporary files – typically 3x the source-file size, or about 200 GB for a complete planet)

After you pip install geodesk, fire up the Python shell and open your GOL (e.g. france.gol):

>>> from geodesk import *
>>> france = Features("france")

Select the features you want:

>>> museums = france("na[tourism=museum]")

(The query language is similar to Overpass: na here means nodes or areas; the desired tags are placed in square brackets)

Visualize these features on a Leaflet-style map:


(This creates an HTML temp file and opens it in a browser; on some flavors of Linux, you will need to explicitly name the file:"paris-museums").show())

Restrict queries to an area:

>>> paris = france("a[boundary=administrative][admin_level=8][name=Paris]").one
>>> paris_museums = museums(paris)

Work directly with individual features:

>>> for museum in museums:
>>>     print(

Find nearby features:

>>> nearby_subways = subway_stops.around(meters=500, museum)

Once you’re comfortable with Python, you can do more interesting things. Here’s how you obtain an alphabetical list of the unique street names in a city:

>>> sorted({ for s in streets(berlin)})

Of course, you’re not limited to pithy one-liners – you can write proper scripts (and entire applications). There are some examples on the Wiki.

What else can you do?

  • Query features based on type, tags and spatial relationships (e.g. intersects, within, contains, connects_to)
  • Measure features: length, area, distance
  • Explore object graphs (nodes of ways, members of relations)
  • Obtain geometric shapes and process them using Shapely (Python wrapper for GEOS)
  • Convert features to various formats (just GeoJSON and WKT for now, but more are coming)

For details, check out the full documentation and the GitHub repository.

Please keep in mind that this is an Early Access release, which means you’ll likely encounter bugs and missing functionality. As always, we appreciate bug reports and other feedback.

You can post general usage questions in Help & Support of this forum (tag your post geodesk for faster responses).

What’s next

These are our plans for the coming months:

  • Ship at least two more releases (to implement all documented capabilities and address any bugs)
  • Port the enhancements in the Python version back into GeoDesk for Java
  • Enable incremental updating for GOLs (#2 most-requested)

We’ll keep you posted on our progress. Thanks for your interest & support!