Console #194 -- An Interview with Geoff of OSMnx - Python for Street Networks
Featuring Zed, Fish, and OpenGFW
🤝 Sponsor
This space is reserved for sponsors that support us to keep the newsletter going! Want to support Console? Send us a note at osh@codesee.io
🏗️ Projects
Browse through open source projects on OpenSourceHub.io, add your project to get more exposure and connect with other maintainers and contributors!
Zed
Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
language: Rust stars: 13668
repo: github.com/zed-industries/zed
site: zed.dev
OpenGFW
OpenGFW is a flexible, easy-to-use, open source implementation of GFW (Great Firewall) on Linux.
language: Go stars: 4601
repo: github.com/apernet/OpenGFW
Fish Shell
Fish is a smart and user-friendly command line shell for macOS, Linux, and the rest of the family. fish includes features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.
language: Rust stars: 23845
repo: github.com/fish-shell/fish-shell
site: fishshell.com
OSMnx
OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
language: Python stars: 4526
repo: github.com/gboeing/osmnx
docs: osmnx.readthedocs.io/en/stable/
Join thousands of other open-source enthusiasts and developers in the Open Source Hub Discord server to continue the discussion on the projects in this week's email!
🎙️ Interview with Geoff of OSMnx - Python for Street Networks
Hey Geoff! Thanks for joining us! Let us start with your background.
I grew up in the Los Angeles suburbs. I am mostly self-taught with programming, but I took a couple Java classes in college. My PhD is in city and regional planning from UC Berkeley. While at Berkeley I taught myself Python, which I work with the most for spatial science computing. I’m currently a professor at USC, and I previously worked as a professor at Northeastern University and as a postdoc at Berkeley.
What is your favorite software tool?
No specific favorite, but most of my research tools revolve around the scientific Python stack, and particularly the geospatial science ecosystem. That includes tools like GeoPandas, Shapely, Rasterio, Cartopy, PySAL, and so forth.
Why was OSMnx started?
I started it as the toolkit underlying my doctoral dissertation (which analyzed US street networks’ geometric and topological properties).
How does OSMnx work?
OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap. You can download and model walking, driving, or biking networks with a single line of code then analyze and visualize them. You can just as easily work with urban amenities/points of interest, building footprints, transit stops, elevation data, street orientations, speed/travel time, and routing.
Using OSMnx’s graph module, you can retrieve any OpenStreetMap spatial network data (such as streets, paths, rail, canals, etc) from the Overpass API and model them as NetworkX MultiDiGraphs (that’s a directed multigraph with possible self-loops and parallel edges). Using OSMnx’s features module, you can search for and download OpenStreetMap geospatial features (such as building footprints, grocery stores, schools, public parks, transit stops, etc) from Overpass API as a GeoPandas GeoDataFrame. This uses OpenStreetMap tags to search for matching elements. OSMnx can also geocode queries for you.
Once you’ve got a model, you can find nearest nodes/edges to coordinates, solve shortest paths, calculate network statistics, plot networks, and more.
Why Python?
Because the existing geospatial and network science ecosystems are rich to build upon
Because it’s a standard language for urban planners, engineers, and geographers to work with
Because it has a low barrier to entry for new non-technical audiences to get started using tools built in Python
Where did the name for OSMnx come from?
OpenStreetMap (OSM) + NetworkX (nx)
Who, or what was the biggest inspiration for OSMnx?
I wrote a paper about that! https://geoffboeing.com/publications/right-tools-for-job/
Are there any overarching goals of OSMnx that drive design or implementation? If so, what trade-offs have been made in OSMnx as a consequence of these goals?
Well the central goal is to be easy to use so that it “just works.” The original goal was to make something so dead simple that anyone could figure it out on Day 1 of learning Python. What that means in practice is you just need one line of pretty intuitive code to completely download and model the street network (or other infrastructure) of any city in the world. Then just 1 more line of code to calculate a large suite of statistics and indicators, or to visualize the network. The tradeoff has been building out a lot of under-the-hood code to handle a lot of different possibilities to make it all work relatively seamlessly.
What is the most challenging problem that’s been solved in OSMnx, so far?
I talk about this in the paper I linked earlier (regarding the project’s inspiration): there’s lots of data on OpenStreetMap, but traditionally it was difficult or required a bunch of ad hoc code to turn it all into a graph-theoretic model for network analytics. OSMnx makes it automatic and theoretically-sound (from an urban/transport geography perspective, and from a network science perspective).
In particular, one thing OSMnx does automatically for you is “correct” the network topology. Its simplification module automatically processes the network’s topology from the original raw OpenStreetMap data, such that nodes represent intersections/dead-ends and edges represent the street segments that link them. This takes two primary forms: graph simplification and intersection consolidation.
Graph simplification cleans up the graph’s topology so that nodes represent intersections or dead-ends and edges represent street segments. This is important because in OpenStreetMap raw data, ways comprise sets of straight-line segments between nodes: that is, nodes are vertices for streets’ curving line geometries, not just intersections and dead-ends. OSMnx simplifies this topology by eliminating non-intersection/dead-end nodes while retaining the complete true edge geometry as an attribute on the simplified edge. This has the side benefit of making most network algorithms run much faster, because most scale with the node count.
Intersection consolidation is important because many real-world street networks feature complex intersections and traffic circles, resulting in a cluster of graph nodes where there is really just one true intersection as we would think of it in transportation engineering or urban design. Similarly, divided roads are often represented by separate centerline edges: the intersection of two divided roads thus creates 4 nodes, representing where each edge intersects a perpendicular edge, but these 4 nodes represent a single intersection in the real world. OSMnx can consolidate such complex intersections into a single node and optionally rebuild the graph’s edge topology accordingly.
What were the existing projects lacking that made you consider building something new?
What I needed just didn’t really exist. You can download raw OpenStreetMap data easily, but that didn’t help me build models with it. Tools like OSRM are great, but didn’t help me calculate the network statistics and indicators I was looking for. It was really a gap in the toolkit that needed filling.
Can you share some real-world use cases or applications where OSMnx has been particularly beneficial?
Pretty Maps has been a really cool downstream use of OSMnx. (Console Interview with Marcelo of Pretty Maps)
I used OSMnx for this project (https://geoffboeing.com/2019/09/urban-street-network-orientation/) studying street network orientation around the world, which got a lot of attention at the time.
I have also used it for visualizing street network “form” around the world to convey how urban planning and local geography shape urban patterns (for example, https://geoffboeing.com/2017/01/square-mile-street-network-visualization/)
I also liked this study from last year that built on some of my work: nature.com/articles/s41586-022-04486-7
Is OSMnx intended to eventually be monetized if it isn’t monetized already?
Nope, despite my wife’s protestations, this is my gift to the world.
What are you most proud of?
Honestly I’m just proud to have made something that other people find useful. I hate the tendency to endless reinvent the wheel in academic spatial science projects, and I think OSMnx has saved a lot of people a lot of time, while opening up new research avenues to lots of folks who needed a tool like this.
How do you balance your work on open-source with your day job and other responsibilities?
One of the nice things about being a professor is you get to choose how you spend your time (as long as you meet the job requirements of teaching X number of classes each semester and publishing Y number of papers to earn tenure). In many ways, supporting this open-source project *IS* my day job because it’s the toolkit that underlies most of my empirical and theoretical research.
Have you ever experienced burnout? How did you deal with it?
Constantly. As an academic, it’s just part of the landscape. I like to joke with my PhD students that being a professor means you have to work 70 hours a week… but you get to pick which 70 hours. Fortunately, I get winter break and summers off, so I can relax and go hiking in the San Gabriel Mountains and traveling for extended periods of time.
What is the best way for a new developer to contribute to OSMnx?
I keep the issue board pretty clean on GitHub, but there are always a few things open. I’m always looking for help with those. In particular right now, folks with experience in adding type annotations to existing codebases would be much appreciated.
Where do you see the project heading next?
I’m hoping to release v2 sometime in 2024. It will add type annotations and offer a new streamlined API that removes a few old deprecated ways of doing things in favor of leaner, more efficient ways.
Are there any other projects besides OSMnx that you’re working on?
I am also on the executive team of this project: healthysustainablecities.org that builds spatial software for calculating indicators of the built environment and its accessibility and walkability in collaboration with local partners around the world.
Like the interview? Receive more interviews like these of your favorite open source projects by subscribing to the free newsletter!
Interested in sponsoring the newsletter or know of any cool projects or interesting developers you want us to interview? Reach out at osh@codesee.io or mention us @ConsoleWeekly!