Chapter 5. OpenStreetMap: Accessing Geospatial Data with OSMnx

OpenStreetMap (OSM) is an editable geographic database of the entire world built by volunteers with an auspicious goal: to create geographic data and distribute it to all of us for free. You have interacted with OSM already on your smartphone if you use GPS for directions—or any location-enabled device. Python offers a package called OSMnx that lets urban planners and a wide variety of other users create street networks and interact with and analyze otherwise “hidden” geographic information. You can find walkable, drivable, or bikeable urban networks for your own personal use or for research, such as to study characteristics of urban environments. Robust analytics reveal infrastructure frameworks that disclose inefficiencies when analyzing the network and interrelated nature of roadways, for example.

Personally, I think street networks are works of art. But their real use, which is perhaps underutilized, is adding geometric shapes to your built infrastructure. You can add buildings (hospitals, schools, and grocery stores, for example), parks, and other dataframes categorized as edges, buildings, and areas. The term building is defined loosely, and there is a Wiki for building tags. A great resource to find place names is OSM Nominatim. You can also add points of interest, elevations, and much more.

At first glance, OSMnx may seem a bit technical and complicated. But as you build street networks with OSM in this ...

Get Python for Geospatial Data Analysis now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.