Welcome back to a new episode of how to become ohsome. Yes, you’ve read the heading correctly. We are really talking about a snake in a notebook on another planet. If you are familiar with one of the most used programming languages in the GIS world, you might already know by now which snake is meant here. We will show you in a Jupyter Notebook how you can use Python to make ohsome queries and visualizations in one go. And we will do that through using our global ohsome API instance. In case you’ve just read the combination of “global” and “ohsome” for the first time, better get up-to-date and read this blog post.
As already mentioned, Python is a widely used programming language, especially in the GIS world, to perform spatial analysis and create visualizations like diagrams. Combining Python code, explanations and visualizations in one go, a Jupyter Notebook is a useful tool to achieve just that. It is already in use within other projects in HeiGIT (e.g. avoid obstacles with ORS). So we thought it was time to make Jupyter Notebooks ohsome.
To give you a little teaser of what is in that notebook, the following shows a visualization plus a piece of Python code that is used to create it. The diagram displays the count of OSM elements having the OSM tag building for different points in time for the three cities Heidelberg, Mannheim and Ludwigshafen.
And here is a part of the Python code that is used in the notebook to create the visualization above:
data = [trace1, trace2, trace3]layout = go.Layout(title = 'Number of OSM buildings in Heidelberg, Mannheim and Ludwigshafen',barmode = 'group',legend = dict(orientation = "h"))fig = go.Figure(data = data, layout = layout)py.iplot(fig, filename = 'groupBy')
The complete Jupyter Notebook with all the code and explanations can be found here. As always, if you want to give us feedback or have any questions, email@example.com is the best way to get in touch with us. Further Jupyter Notebooks with more examples will follow soon. Stay ohsome!