ohsome-py: Python Package for OSM history analytics published

As a little Easter present, we published the first version of the ohsome-py Python package today. ohsome-py helps you extract and analyse OpenStreetMap history data using the ohsome API and Python. It handles queries to the ohsome API and converts its responses to Pandas or GeoPandas data frames to facilitate easy data handling and analysis. In this way, you can use Python’s rich plotting libraries to create figures like the one below with just a few lines of code. Check out this notebook to see how it was produced.

The project is still in an early stage, so there might be quite some changes to the package in the future. To learn how ohsome-py works continue reading below or get started with the tutorial.

Installation

ohsome-py requires Python >= 3.6. Install ohsome-py using pip:

$ pip install ohsome

Usage

Start Python and create an OhsomeClient instance which handles all requests to the ohsome API.

from ohsome import OhsomeClient
client = OhsomeClient()

A simple query to count the number of OSM features tagged as building=* looks like this:

response = client.elements.count.post(bboxes=[8.625,49.3711,8.7334,49.4397],
				      time="2010-01-01/2020/01-01/PY1",
                                      filter="building=* and type:way")

To send a request to one of the ohsome API endpoints append the single components of the endpoint URL as method calls to the client (similar to regular method chaining in Python) and finally call the post() method which contains all necessary query parameters.

To easily analyse and plot the data, the response can be converted to a Pandas DataFrame or a GeoPandas GeoDataFrame if the response contains geometries.

response_df = response.as_dataframe()

Now you can start your own ohsome analysis of OSM history data!

Further info on the ohsome Framework:

Information on the ohsome OpenStreetMap History Data Analytics Platform and more examples of how to use the ohsome API can be found here:

Related Literature:

For some recent work that has been accomplished using ohsome see for example