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.
ohsome-py requires Python >= 3.6. Install ohsome-py using pip:
$ pip install ohsome
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:
- ohsome general idea
- ohsome general architecture
- the whole “how to become ohsome” tutorials series
- Raifer, Martin; Troilo, Rafael; Kowatsch, Fabian; Auer, Michael; Loos, Lukas; Marx, Sabrina; Przybill, Katharina; Fendrich, Sascha; Mocnik, Franz-Benjamin; Zipf, Alexander (2019): OSHDB: a framework for spatio-temporal analysis of OpenStreetMap history data. Open Geospatial Data, Software and Standards.
For some recent work that has been accomplished using ohsome see for example
- Ludwig, C., Fendrich, S., Zipf, A. (2020): Regional Variations of Context-based Association Rules in OpenStreetMap. Transactions in GIS DOI: 10.1111/tgis.12694
- Schott, M.; Grinberger, A.Y.; Lautenbach, S.; Zipf, A. The Impact of Community Happenings in OpenStreetMap—Establishing a Framework for Online Community Member Activity Analyses. ISPRS Int. J. Geo-Inf. 2021, 10, 164. https://doi.org/10.3390/ijgi10030164
- Herfort, B., Lautenbach, S., Porto de Albuquerque, J., Anderson, J., Zipf, A. (2021): The evolution of humanitarian mapping within the OpenStreetMap community. Scientific Reports 11, 3037 (2021).
- Auer, M.; Eckle, M.; Fendrich, S.; Griesbaum, L.; Kowatsch, F.; Marx, S.; Raifer, M.; Schott, M.; Troilo, R.; Zipf, A. (2018): Towards Using the Potential of OpenStreetMap History for Disaster Activation Monitoring. ISCRAM 2018. Rochester. NY. US.
- Wu, Zhaoyan, Li, Hao, & Zipf, Alexander. (2020). From Historical OpenStreetMap data to customized training samples for geospatial machine learning. In proceedings of the Academic Track at the State of the Map 2020 Online Conference, July 4-5 2020. DOI: http://doi.org/10.5281/zenodo.3923040