Latest / Talk Python To Me / #495: OSMnx: Python and OpenStreetMap
Transcript
- 0:00On this episode, I'm joined by Dr. Jeff Boeing, an assistant professor at the University of Southern California,
- 0:05whose research spans urban planning, spatial analysis, and data science.
- 0:09We explore why OpenStreetMap is such a powerful source of global map data,
- 0:14and how Jeff's Python library, OSMNX, makes that data easier to download, model, and visualize with Python.
- 0:21Along the way, we talk about what shapes city streets around the world,
- 0:24how urban design influences everything from daily commutes to disaster resilience,
- 0:30and why turning open data into accessible tools can open up completely new ways of understanding
- 0:36our cities. If you've ever wondered how to build or analyze your own digital maps in Python,
- 0:42you won't want to miss this conversation. This is Talk Python To Me, episode 495,
- 0:47recorded Thursday, January 16th, 2025.
- 0:51Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy.
- 1:09Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython,
- 1:15both accounts over at fosstodon.org. And keep up with the show and listen to over nine years
- 1:20of episodes at talkpython.fm. If you want to be part of our live episodes, you can find
- 1:26the live streams over on YouTube, subscribe to our YouTube channel over at talkpython.fm/youtube
- 1:31and get notified about upcoming shows. This episode is sponsored by Posit Connect from
- 1:37the makers of shiny, publish, share and deploy all of your data projects that you're creating
- 1:41using Python streamlet dash shiny bokeh FastAPI flask quarto reports, dashboards and API's
- 1:50Posit Connect supports all of them.
- 1:52Try Posit Connect for free
- 1:53by going to talkpython.fm/posit, P-O-S-I-T.
- 1:58And it's also brought to you by us
- 2:00over at Talk Python Training.
- 2:02Did you know that we have over 250 hours of Python courses?
- 2:07Yeah, that's right.
- 2:07Check them out at talkpython.fm/courses.
- 2:11Jeff, welcome to Talk Python To Me.
- 2:13- Thank you for having me.
- 2:14- It's great to have you here.
- 2:16We're gonna talk maps and consuming map data
- 2:20a lot of interesting research that you've done with that data.
- 2:23So you have a very cool project, OSMNX, Open Street Map Network X,
- 2:29that we're going to dive into.
- 2:31And it really makes all of this street and map data
- 2:35super accessible to users of Python, right?
- 2:37- Yeah. - Yeah.
- 2:39Excellent. I'm really looking forward to talking about that.
- 2:40Before we dive into it though, just a quick introduction.
- 2:44Who are you?
- 2:44- My name is Jeff Boeing.
- 2:45I'm an assistant professor
- 2:47at the University of Southern California
- 2:50in Los Angeles. I'm in its Department of Urban Planning and Spatial Analysis. And
- 2:55most of my research and teaching are around that intersection of urban
- 3:00planning and spatial analysis. I did my PhD in city planning at UC Berkeley and
- 3:05my focus is on urban data science. So using Python tools, usually open data, to
- 3:11try to understand cities and housing markets and transportation networks and
- 3:16how people move through space,
- 3:18how we can make our cities more resilient
- 3:21to natural disasters, which is relevant in LA this week.
- 3:24Also more equitable, nicer places to walk around,
- 3:28and basically just better for urban living.
- 3:31- Okay, well, that sounds like amazing, amazing research.
- 3:35It's probably interesting to live in LA
- 3:36as one of the bigger, crazier locations
- 3:40in terms of traffic and congestion and population.
- 3:43It's not New York in terms of density,
- 3:45but it's probably its own special beast, I imagine.
- 3:48- Yeah, it is.
- 3:49LA is an ironic place to be an urban planning professor
- 3:52because it can be so frustrating
- 3:54for a lot of our best practices in urban planning,
- 3:57but at the same time,
- 3:58there is no better place in the US to be studying
- 4:01and trying to intervene into some of these crises
- 4:04that urban planning has wrought.
- 4:06- Yeah, yeah, a lot of it was just,
- 4:08I imagine in the early days, just a free for all, right?
- 4:11There was people, especially out in the West, right?
- 4:14the US West, people just move out there
- 4:16and there's not a whole lot going on.
- 4:18So when a city just neighborhoods go that way
- 4:21and not quite enough density for a lot of public transit
- 4:24makes it challenging.
- 4:26And then they become huge cities
- 4:27but they're stuck with those consequences.
- 4:29Like LA and other cities. - Yeah, exactly.
- 4:30And it's hard to retrofit a city once it's built out
- 4:33because those are people's homes and private properties
- 4:36that you can't just cut from whole cloth,
- 4:39lay down the new city plan.
- 4:40- Yeah, yeah.
- 4:41Are there cities out there that are basically planned
- 4:44from scratch?
- 4:46- Yeah, there are places like Brasilia,
- 4:49the capital of Brazil was a master planned city
- 4:54in the modernist era, mid-century city planning
- 4:57where it's designed to look almost like the shape
- 4:59of an airplane for the jet age,
- 5:02a modern city for the jet age.
- 5:03- Amazing.
- 5:04- But there's a wide range of how cities come to be.
- 5:08Some of them are very organic,
- 5:09like you think old medieval cities
- 5:11have formed over centuries.
- 5:14There are places like LA that built out very rapidly,
- 5:17or like in Chicago, all these straight lines
- 5:20following from these 19th century ideas of rationality
- 5:25and orthogonal street networks.
- 5:28And then there are these master plan cities
- 5:30where strong central leadership lets you lay it down
- 5:33however you think is best.
- 5:36- I imagine that how the cities are built
- 5:39has a lot to do with the people who helped construct the city
- 5:43or there in the early days, how they perceived distance.
- 5:46People perceived distance in LA by how far can you go
- 5:50in a car in 20 minutes.
- 5:51The people perceived distance in Stuttgart,
- 5:54how far can you walk?
- 5:55Maybe you can take a horse, potentially.
- 5:58And that really probably changes things.
- 6:00- Yeah, you know what, one way we talk about that idea
- 6:03of the perception of distance
- 6:04and how the urban form shapes up
- 6:07is this idea of transportation technologies
- 6:09And in general, you really see something of a death of geography.
- 6:15That is, if you look at a 1990s suburb of Philadelphia or of Los Angeles, they look
- 6:22very similar to each other.
- 6:24You don't see that sort of local culture.
- 6:27What you see is really building around the transportation technology and design aesthetic
- 6:32of the era, rather than the local hands building the place up.
- 6:36And it's, you know, when cars are how you get around,
- 6:39you build a city, it's designed for cars.
- 6:41- Yeah, and then the cars get to be huge SUVs
- 6:44and they still don't fit.
- 6:45All right.
- 6:47Let's talk, you have this really cool visualization,
- 6:50which I'm going to link to in the show notes,
- 6:53called City Street Orientations Around the World.
- 6:56And it's got some pretty wild graphics.
- 7:00You wanna tell people about this
- 7:01and kinda try to describe it for the folks listening?
- 7:04Yeah, so what these show is the orientation
- 7:09of your city streets.
- 7:10By orientation, we mean on a compass.
- 7:12Like, do they point north, south, east, west?
- 7:15Are they off that north, south, east, west orientation?
- 7:19Or do your streets point more chaotically
- 7:21in all directions around the compass?
- 7:23Like, there isn't a more consistent orientation.
- 7:26So to visualize these, I used what's basically
- 7:30just a histogram, but it's a polar histogram.
- 7:33So where a normal histogram will count your observations
- 7:37across some set of bins, for a polar histogram,
- 7:40we've wrapped those bins around the circle of a compass
- 7:44so that each bin represents 10 degrees around the compass.
- 7:49And there's 36 bins total for 360 degrees around the circle.
- 7:53And then the length of each of the bars in those bins
- 7:57represents the frequency of streets
- 7:59pointing in that direction in the city.
- 8:02So in a place like Chicago or Beijing on screen here,
- 8:08most of the streets point north, south, east, west.
- 8:11And what that tells us is it's kind of grid-like.
- 8:14And this is common in a lot of cities around the world.
- 8:16Even a lot of pre-modern cities
- 8:19would still orient themselves generally
- 8:21north, south, east, west,
- 8:22just based on patterns where the sun was rising and setting.
- 8:25- Yeah, I'm super surprised to see, for example,
- 8:27of Barcelona is pretty, not north-south,
- 8:30but it's 90 degrees.
- 8:32- Yeah, so in Barcelona, you see that 19th century
- 8:36and early 20th century, Eixample development.
- 8:40So around medieval old Barcelona,
- 8:43El Defensor de la Dada laid out his grand city plan
- 8:46that is fairly grid-like around it.
- 8:48You can really see that here.
- 8:49- Yeah, absolutely.
- 8:50For people listening, some of them look like
- 8:53airplane fore-blade propellers,
- 8:54and some look maybe like boat propellers,
- 8:57like really dense, but yeah, it's quite wild
- 8:59to get a quick look.
- 9:01Do we have LA in there?
- 9:02We must, right?
- 9:04- I have LA in the big one.
- 9:06If you scroll down, we have American cities.
- 9:08- Oh yeah, yeah, yeah.
- 9:10Okay. - Yeah, there it is.
- 9:11- That's a pretty stark contrast.
- 9:12It's like all of them are propeller looking.
- 9:15Other than Boston and interestingly, Charlotte.
- 9:18Boston has a city. - Yeah, really interesting.
- 9:19- Yeah, but Charlotte doesn't feel like a city
- 9:21like that to me, but what do we have?
- 9:23- Yeah, so Boston is kind of one of those pre-modern,
- 9:26American cities. And its street orientation looks like that for a couple
- 9:32of reasons. One, Boston is an agglomeration of multiple smaller towns
- 9:36over several centuries and each of them had grids to some extent but they didn't
- 9:41all face the same way so they all got merged together. And then it has a lot of
- 9:45hills that made it harder to build especially in early days and it would
- 9:49really predated America's obsession with grids. Charlotte is kind of the opposite
- 9:54it's late 20th century, the sort of winding streets
- 9:57and cul-de-sacs to make up those arterial roads
- 10:02and then these sort of secluded in the center
- 10:04super blocks of subdivisions.
- 10:07- Nice, well I'm happy to see that Portland, where I live,
- 10:09is like a perfect propeller blade shape.
- 10:12You know, in our town, you have northeast, northwest,
- 10:16southeast, and then street numbers,
- 10:17like northeast 120th street, right?
- 10:20And it just screams we're on a perpendicular
- 10:24North Southeast West grid and it definitely shows up here.
- 10:27And so this is some of the stuff that you came up with OSM NX.
- 10:31- Yeah, so I used OSM NX to build all of these
- 10:35street network models from OpenStreetMap data.
- 10:38And then OSM NX has built into it a visualization module
- 10:43that creates these kind of polar histograms
- 10:45to understand how streets are oriented.
- 10:48- Awesome, it's super interesting.
- 10:49Let's, it's like it communicates to you just immediately
- 10:54as you look at it, it's great.
- 10:55Let's start by talking about OpenStreetMap.
- 10:58This is the backing data, obviously,
- 11:01the important backing data of your library.
- 11:03So what's the origin of OpenStreetMap?
- 11:07- Yeah, so OpenStreetMap started maybe 20 years ago or so.
- 11:12For folks who haven't seen it before,
- 11:14I often describe it as being akin
- 11:16to Google Maps meets Wikipedia.
- 11:18So it's a worldwide mapping project with global coverage.
- 11:23Anyone can edit or contribute to it.
- 11:26There is some editorial oversight as well to validate those edits.
- 11:32But what's cool about OpenStreetMap is that its data license allows you to
- 11:37pull data from it.
- 11:39So unlike, say, Google Maps, which is fairly limited in what all it can draw,
- 11:45you can really pull all of these features from OpenStreetMap.
- 11:48And if you look, if you just zoom in on one of these cities here.
- 11:51>> Yeah, let's go to Riverside, yeah.
- 11:53- Yeah, it was surface streets, rail lines,
- 11:56building footprints, parks, train stations,
- 11:59often grocery stores, restaurants, public schools.
- 12:02All this stuff we're interested in
- 12:04from an urban planning perspective.
- 12:06- Yeah, oh, it's really interesting.
- 12:09And you can add in additional layers,
- 12:11like cycling maps or transportation maps
- 12:15or topology maps, topological maps,
- 12:18all sorts of interesting things here.
- 12:20- Yeah, exactly.
- 12:21And it really lets you kind of hone in
- 12:24on the specific characteristics of the city
- 12:27that you're interested in.
- 12:29And there's a humanitarian layer that you can see,
- 12:32and this has been one of the big uses of OpenStreetMap
- 12:35now for 15 years or so.
- 12:40Often when there is a disaster in a less developed country,
- 12:45humanitarian aid organizations will go in
- 12:48and use OpenStreetMap and contribute to it
- 12:50to create a kind of a digital layer
- 12:53of the facts on the ground.
- 12:55So the Haiti earthquake a few years back
- 12:57was a primary example of that,
- 13:00where it helped them understand where urbanization was,
- 13:03where there were water pumps, toilets, and so forth,
- 13:06the kind of things that people need,
- 13:08but aren't well mapped, often in these informal settlements.
- 13:12- Yeah, oh, it's amazing.
- 13:13We have, you know, I think everyone was amazed
- 13:16when Google Maps came out, right?
- 13:19Before then we had MapQuest and all those things.
- 13:21You'd have big little up arrow, up arrow, right arrow
- 13:23to like pull in tiles of the world and you know,
- 13:26Google Maps and the world view that they had.
- 13:28What was that product called?
- 13:30Remember?
- 13:31Where you could kind of fly, it was like a 3D thing.
- 13:33You could kind of fly around in the early days
- 13:35but it was the same basic data thing.
- 13:36Anyway, when that stuff came out, it was like,
- 13:38wow, this stuff is, you can now know about the world.
- 13:40You can say, where did that road go?
- 13:42I never went down.
- 13:43You could just follow it and see
- 13:44or go to street view or whatever.
- 13:46But a lot of that is locked behind.
- 13:48however Google wants you to use it, right?
- 13:51And it's not super accessible.
- 13:53And so having something like this,
- 13:55where people can contribute,
- 13:56especially if they care about their neighborhood, right?
- 13:58A lot of this people are contributing back
- 14:00into OpenStreetMap data.
- 14:02- Yeah, exactly.
- 14:05Yeah, so the nice thing with this is that
- 14:07it really is much more in that open source,
- 14:09open data model of the world,
- 14:11which means we can do open science with it,
- 14:13citizen science with it.
- 14:15People who just notice that stuff is missing
- 14:17in their own community, you're able to fix it.
- 14:20It's no longer that frustration of,
- 14:21well, when will Google get this thing right?
- 14:24Or, hey, we have this new highway
- 14:25that was built outside my town.
- 14:27When's it gonna show up?
- 14:28I mean, it's up to you.
- 14:29You can make it show up later today.
- 14:31There is a drawback to that though.
- 14:33The drawback is you get what we call sampling biases.
- 14:36That is, you tend to see more coverage
- 14:38in places where people tend to contribute more.
- 14:42And those things tend to be correlated
- 14:43with demographic characteristics.
- 14:46Men contribute more than women.
- 14:47higher income places more than lower income places
- 14:51just from a resourcing perspective.
- 14:53And so one of the challenges we face as researchers
- 14:56using OpenStreetMap data for our analytics work
- 15:00is keeping those in mind
- 15:02because it's hard to do comparative analysis.
- 15:04If you don't know it's because the infrastructure
- 15:06is actually different in two places
- 15:08or because it's been digitized to a different extent
- 15:10in two places.
- 15:11- Right, right, right.
- 15:12Just maybe higher fidelity information
- 15:15might skew some analysis one way or another, right?
- 15:18- That's right, exactly.
- 15:19And it tends to work pretty well comparatively
- 15:21for stuff like roads, streets,
- 15:24whereas things like pedestrian footpaths
- 15:27or fresh food markets might be well digitized
- 15:30in San Francisco and Portland,
- 15:32but probably not, say, in a small town in India
- 15:35or Indonesia, let alone like a suburb of Des Moines, Iowa.
- 15:38- Yeah, yeah, absolutely.
- 15:40One of the apps that I use a lot is OnX.
- 15:43You know OnX?
- 15:44- Yeah, OnX is cool.
- 15:46You can, I do a lot of off-road motorcycle riding
- 15:49and it'll show you all the little trails and stuff,
- 15:52but someone's got to go and enter all that information.
- 15:55And so some places are super well mapped
- 15:58and others are not on the map at all.
- 16:00But I imagine they probably get some of their data
- 16:03from OpenStreetMap as well,
- 16:04although I haven't been able to tell.
- 16:06- Yeah, it's a good question.
- 16:06A lot of people downstream do use OpenStreetMap data
- 16:10because of its quality and accessibility.
- 16:13- Yeah, Mark out in the audience is asking,
- 16:15is there some kind of mobile app that kind of gives you
- 16:18access to the OpenStreetMap data?
- 16:21Kind of like Google Maps.
- 16:21- Yeah, there are some mobile apps for it.
- 16:26I don't use them.
- 16:27It has some challenges with routing
- 16:29because it is publicly editable.
- 16:32Sometimes there'll be little breaks in the connections
- 16:34where it's not digitized quite right.
- 16:37But there are routing apps.
- 16:38You could replace, say, Google Maps on your phone
- 16:40with OpenStreetMap and you can route with it.
- 16:42It works particularly well in big cities
- 16:45and places like Europe and the US,
- 16:47less so in small rural areas or in less developed countries.
- 16:51- Yeah, yeah, the onX thing is,
- 16:53it doesn't really route you,
- 16:54but it shows you on a map
- 16:56and then it shows you where you go on it,
- 16:57and if you choose to stay on the path,
- 16:59then it'll really help you,
- 17:00but it doesn't really say,
- 17:02you can't say, "Give me directions."
- 17:05At least not when you're off-road.
- 17:07If you're on-road, maybe it'll fall back
- 17:09to something that works, but yeah, amazing.
- 17:11- So what's the licensing story behind all this data?
- 17:14How, the name probably gives a lot of it away,
- 17:17OpenStreetMap, but how is this data usable?
- 17:19What can people do with it?
- 17:20- Yeah, so it's basically usable
- 17:23for non-commercial purposes with attribution.
- 17:26So for example, as researchers,
- 17:29when we are using these data,
- 17:32we just need to attribute where it came from,
- 17:35OpenStreetMap and its contributors.
- 17:38And I ended up including that license information
- 17:41somewhere on the read me for OSMNX,
- 17:45because I think a lot of time people will look over
- 17:48these underlying data sources and tools
- 17:50when they're using these kind of downstream,
- 17:53downstream tools and apps.
- 17:56So because of that, I just wanted to call it,
- 17:58yeah, you can see it on screen here.
- 18:00So I mentioned OpenStreetMaps open data license
- 18:02requires that derivative works provide proper attribution,
- 18:06which is really nice 'cause it's a very easy thing to do
- 18:08for the cornucopia of data that they make available.
- 18:11- Yeah, yeah, that's amazing.
- 18:14This portion of Talk Python To Me
- 18:16is brought to you by the folks at Posit.
- 18:18Posit has made a huge investment
- 18:19in the Python community lately.
- 18:21Known originally for RStudio,
- 18:23they've been building out a suite of tools
- 18:25and services for Team Python.
- 18:27Over the past few years,
- 18:28we've all learned some pretty scary terms,
- 18:31of squatting, supply chain attack, obfuscated code, and more. These all orbit around the idea
- 18:38that when you install Python packages, you're effectively running arbitrary code off the
- 18:43internet on your dev machine, and usually even on your servers. The thought alone makes me shudder,
- 18:48and this doesn't even touch the reproducibility issues surrounding external packages.
- 18:53But there are tools to help. Posit Package Manager can solve both problems for you.
- 18:58Think of Posit Package Manager as your personal package concierge.
- 19:02You use it to build your own package repositories within your firewall that keep your project safe.
- 19:07You can upload your own internal packages to share or import packages directly from PyPI.
- 19:12Your team members can install from these repos in normal ways using tools like pip, poetry, and uv.
- 19:18Posit Package Manager can help you manage updates ensuring you're using the latest,
- 19:23most secure versions of your packages. But it also takes point-in-time snapshots of your
- 19:28repos, which you can use to rerun your code reproducibly in the future.
- 19:33Posit Package Manager reports on packages with known CVEs and other vulnerabilities
- 19:38so you can keep ahead of threats.
- 19:40And if you need the highest level of security, you can even run Posit Package Manager in
- 19:44air-gapped environments.
- 19:46If you work on our data science team where security matters, you owe it to you and your
- 19:50org to check out Posit Package Manager.
- 19:52visit talkpython.fm/ppm today
- 19:56and get a three month free trial to see if it's a good fit.
- 19:58That's talkpython.fm/ppm.
- 20:01The link is in your podcast player show notes.
- 20:03Thank you to Posit for supporting the show.
- 20:07If I wanted to build a commercial product,
- 20:10I wanted to build on X squared or whatever,
- 20:12where I could have people drive around and use that
- 20:14and map it and make notes and maybe contribute back.
- 20:17Do you know what the story,
- 20:18I mean, obviously not a lawyer, right?
- 20:20But what's the, would people be able to do that?
- 20:23Or is there a paid API or how does it work?
- 20:25- It's a good question.
- 20:27So I know in practice people can
- 20:29because I see commercial tools
- 20:30that use OpenStreetMap data all the time.
- 20:32I don't know the details though
- 20:34because one of the nice things about being in academia
- 20:36is you end up being so divorced from the commercial world
- 20:39that I don't have to worry about that.
- 20:41- Yeah, that's pretty good, right?
- 20:44Just do your research, answer interesting questions
- 20:47and follow the lead, right?
- 20:48- Those are the benefits, yeah.
- 20:49It comes with drawbacks, but those are the benefits.
- 20:52- Yeah, I'm aware of some of the drawbacks as well,
- 20:54for sure.
- 20:55All right, well, so that is the foundation
- 20:59of this project, OSMNX.
- 21:01Tell us about your project.
- 21:03- Yeah, so OSMNX is a Python package
- 21:07that lets you interact with OpenShift's APIs
- 21:10to make it really easy to download data
- 21:12and build models or a data frame of those data.
- 21:17So the two main things that it does is it can create a graph model.
- 21:22So that is a model of a network like streets or rails or highways or anything else.
- 21:30Or you can create a geo data frame.
- 21:31That's kind of a spatialized version of a pandas data frame using GeoPandas of OpenStreetMap features.
- 21:38So that's all the stuff in OpenStreetMap.
- 21:40It could be points, lines, polygons.
- 21:43It could be traffic signals or parks or schools or roads.
- 21:48But you can download either of those
- 21:50and then do whatever it is you wanna do with them.
- 21:53And OSMNX has some other stuff built in.
- 21:56So it has a simple routing engine built in,
- 21:59some visualization tools.
- 22:02You can work with elevation
- 22:04so that you can figure out street grades.
- 22:07Particularly relevant, for example, if you're a cyclist
- 22:10and you're trying to choose a shortest path
- 22:12that maybe minimizes those grades and so forth.
- 22:15- Even for cars, Google started offering a,
- 22:19this path saves, uses the least fuel,
- 22:22or in my case, the least electricity,
- 22:24whatever you put into it to make it go.
- 22:28That's also, uses like that would be interesting.
- 22:32- Yeah, exactly.
- 22:33I mean, kind of superficially,
- 22:34we always imagine that our shortest path to get somewhere
- 22:37is the one that minimizes our travel time.
- 22:39But in reality, there are a lot of other things
- 22:42minimize including fuel consumption or for pedestrians.
- 22:45Empirically, we know that people will take
- 22:48longer routes if it's a nicer route.
- 22:50We're not trying to shave off a minute to walk along
- 22:52the arterial road with the aluminum.
- 22:55>> You go through the fence
- 22:59by that old abandoned factory back here,
- 23:00and you go straight across, it'll be great.
- 23:03You'll save a minute.
- 23:05>> Exactly.
- 23:07>> Amazing. Okay. Yeah, super fun.
- 23:09As part of those visualizations,
- 23:11Can you draw maps?
- 23:13You can, yeah. So it has some mapping capabilities.
- 23:17You can also plot routes on it.
- 23:20It ties into a folium package,
- 23:24which is a Python package to develop leaflet JavaScript web maps.
- 23:28So you can do interactive web maps from it.
- 23:31And then on top of OSMNX, there's a cool downstream package
- 23:37called Pretty Maps that I'm not affiliated with,
- 23:39but does really nice, aesthetically pleasing mapping.
- 23:44It's really customizable and really cool.
- 23:46>> Okay. Do you have a gallery or something?
- 23:48>> I do. Yeah. So if you scroll up a little bit,
- 23:51there's a link to the examples gallery.
- 23:53It's on GitHub, OSMNX examples.
- 23:57>> You can pull up different notebooks?
- 23:59>> Yeah, exactly. So each notebook covers a different theme of analysis.
- 24:03It would be commonly done with OSMNX.
- 24:06>> Oh, nice. Yeah, that's really cool.
- 24:07People just pull up the notebook and see how it works.
- 24:09What one do you think is a good representative one
- 24:11to maybe like get a sense of how to work with it?
- 24:13- So we count from zero
- 24:15'cause we're in the Python world.
- 24:16So notebook zero zero is a good place to start.
- 24:19That kind of steps through some of the basic functionality
- 24:22that most users would be interested in starting with.
- 24:26- Sure, okay.
- 24:28Yeah, so people can download these notebooks
- 24:30in the examples repository, which I'll link to.
- 24:34- Yeah, exactly.
- 24:34So there's a getting started guide in the documentation
- 24:38after kind of reading through that,
- 24:40that examples gallery is a really good way
- 24:42to just kind of get a sense of code
- 24:44that you can copy and paste to get started.
- 24:46- Okay, excellent.
- 24:47And 5,000 GitHub stars, almost a thousand forks.
- 24:51You know, that's quite a bit of traction.
- 24:52Congratulations.
- 24:53- Yeah, thanks.
- 24:54I mean, it's weird.
- 24:55This is very much my side hustle,
- 24:57but it's also really been a labor of love
- 25:00for a long time now.
- 25:02There is no reward in academia
- 25:05for creating open source packages.
- 25:08I think if you explain it very carefully
- 25:10to academic power brokers, they say,
- 25:13"That makes sense, that's great, that's a good contribution."
- 25:15But prima facie, that doesn't mean anything.
- 25:18They have no idea.
- 25:19- It's really, it's tough to put it
- 25:20on a 10-year application, right?
- 25:22- Yeah, it makes it sound like you're wasting your time
- 25:25and you don't understand what you're supposed to be doing
- 25:27with your time.
- 25:29(laughing)
- 25:29- Like, but you understand, the research is so easy now.
- 25:32- Yeah.
- 25:33I mean, that's really how that started.
- 25:34I thought I was gonna be able to do this research
- 25:37without having to create my own tool,
- 25:39but it turned out I was not able to.
- 25:41- Interesting, what was your background
- 25:42in programming at that point?
- 25:45- Yeah, so my undergrad and master's degree,
- 25:49I did computer systems and information systems.
- 25:53I worked in the private sector for a few years
- 25:56and decided to go back to school
- 25:56for my PhD in urban planning.
- 25:59But when I was coming into that,
- 26:00I was pitching myself as this sort of like
- 26:03data science analytics kind of person in that world,
- 26:07which was starting to get kind of hot at that time.
- 26:09So it ended up being a nice fit.
- 26:12And when I started my dissertation,
- 26:14I had this dissertation proposal that was, you know,
- 26:19very, very nice, this kind of big grand proposal.
- 26:21I ended up only doing the first chapter of it
- 26:23for my entire dissertation
- 26:25because of how these things expand to fill space.
- 26:27And when I pitched my proposal to my dissertation committee,
- 26:31there are a lot of assumptions about the tools
- 26:33that were out there.
- 26:33You know, I knew OpenStreetMap was out there.
- 26:35I'd seen there were some tools to download
- 26:37and work with data from it.
- 26:38So I was pretty sure we'd be able to create
- 26:40a nice mathematical graph model
- 26:43of OpenStreetMap data automatically.
- 26:46As I started on my first week of making that happen,
- 26:49I realized the tool did not exist.
- 26:51And in fact, it was profoundly difficult
- 26:54to get data from OpenStreetMap.
- 26:56If you wanted to filter it,
- 26:57like I just want pedestrian paths, not everything.
- 27:01I just want drivable streets, not everything else.
- 27:04And so the first year of my dissertation work
- 27:06was creating the first version of OSM and X accordingly.
- 27:11- So you must have grants and stuff for your research
- 27:15as academics do.
- 27:17How much time are you allowed to sort of bring some of that
- 27:20into adding features back to this project?
- 27:24- Yeah, back to the benefits of academia,
- 27:27the nice thing is as long as you get
- 27:29what they want to see done,
- 27:31as long as those outputs are there,
- 27:32your time is really completely your own, right?
- 27:34So you teach a couple classes,
- 27:36you have to publish a few papers a year.
- 27:37Other than that, you're free to do whatever.
- 27:39So I do get grants, helps me fund my graduate students.
- 27:44Ironically, it's very hard to get grants
- 27:46to do this kind of open source software,
- 27:49open commons development.
- 27:52Everyone talks about it,
- 27:53and especially grant funders know
- 27:54how much we all use this stuff,
- 27:56and they really like it,
- 27:57but it just doesn't get funded.
- 27:59So what you have to do is you have to kind of hack it in
- 28:03or sideload it, I guess, into your grants
- 28:06where the grant will answer this empirical question
- 28:08that's near and dear to the funder's heart.
- 28:10But to do that, we have this tool building phase
- 28:12for six months, be able to unlock the analytics for it.
- 28:16And so that's really how a lot of the features
- 28:19and a lot of the modules have been added to OSMNx over time.
- 28:23There's this new project I ought to do,
- 28:25so we'll just build it into the package.
- 28:27- Right, we need to be able to answer new questions,
- 28:30so we gotta have new ways to get to the data, yeah?
- 28:32- Yeah, exactly.
- 28:34And it is poorly incentivized in academia,
- 28:38but academia has really been home
- 28:39to a lot of open source tool development,
- 28:42especially niche tools, you know,
- 28:44from stuff like Astropy,
- 28:47for the astronomers and astrophysicists,
- 28:49to things like PySAL,
- 28:51the Spatial Analysis Library in Python,
- 28:53but a lot of things that academics
- 28:54have kind of been at the forefront of,
- 28:56But for us, it's always a side hustle.
- 28:58- Right, stuff with biology, psychology,
- 29:00a lot of the sciences, I imagine.
- 29:02- Yeah, yeah.
- 29:02- Working on open source projects like this
- 29:05feels to me very much like the concept
- 29:08of funding basic science, right?
- 29:11Not funding, we need to solve this problem
- 29:13so we can create a bomb or new energy or go to space,
- 29:17but we're just doing it
- 29:18'cause we need to understand the science better
- 29:20and it'll help us then apply it eventually,
- 29:23maybe, at some point, right?
- 29:24Same sort of thing here.
- 29:26If these exist, it will supercharge the urban planning space
- 29:31to a huge degree, but getting people to fund it
- 29:34or to care about helping build that up,
- 29:37I imagine it's a little bit frustrating.
- 29:39- No, that's exactly, I mean, the way I talk about it
- 29:42is it really is a sort of basic science work
- 29:44that everyone takes for granted
- 29:46as though these things just exist, right?
- 29:49This tool just exists, we don't know where it comes from,
- 29:52it has an API, that API just exists,
- 29:55And it really kind of obscures all of these human decisions
- 29:59and social structures and processes and institutions
- 30:03that make it difficult or make other things easy
- 30:06and really shape what we end up being able to work with.
- 30:09- Yeah, absolutely.
- 30:11Well, someday maybe you can put down,
- 30:13yeah, I only wrote two papers,
- 30:15but I have 10,000 get up stars, so.
- 30:18- Yeah, well.
- 30:19- Here's your tenure assignment, you know.
- 30:22This is the future, I'm there for it.
- 30:26- It's a race between whether ChatGPT overtakes
- 30:29all of that stuff or you get there and people,
- 30:31I don't know, that's a whole different deal.
- 30:33We can talk about that later.
- 30:36Let's talk about the Overpass API though.
- 30:38That's the way that you get data from OpenStreetMap.
- 30:43What is this?
- 30:44- Yeah, so the Overpass API is another open source tool
- 30:52OpenStreetMaps database and download stuff, basically,
- 30:56any of OpenStreetMaps features.
- 31:00So what's nice about Overpass is that there's some public
- 31:03instances that you can just query as a web API.
- 31:07You can also host it locally if you want to work around
- 31:11throttling limits, rate limits.
- 31:15Challenge with the Overpass API--
- 31:18you can see a little bit of it here on screen-- is that the
- 31:20OverpassQL, it's query language,
- 31:23can be really hard to work with to do complex stuff.
- 31:28So this is a fairly simple one.
- 31:29On screen we can see there's a bounding box
- 31:31with some lat long coordinates
- 31:33to explain where we wanna download data from.
- 31:37The output will be in JSON format.
- 31:39The server timeout is 90 seconds.
- 31:42Big queries can take a long time to run.
- 31:45And then we're querying here for way elements.
- 31:48So way would be a line feature in OpenStreetMap.
- 31:53Any line, it could be street,
- 31:55it could also be the building footprints boundary line.
- 31:59- I see, the property lines are zoning or whatever, right?
- 32:04- Yeah, exactly.
- 32:04Anything represented as a line.
- 32:07And so we get that back out, it'll be kicked out as a JSON.
- 32:12And what OSMNx does is it works with this overpass API
- 32:15to try to automate some of these queries.
- 32:18So rather than having to write the query yourself,
- 32:20download the data, and then convert that raw
- 32:22OpenStreetMap data into a useful data format,
- 32:25like drop it into Geopandas or into a NetworkX graph,
- 32:29it assembles all of that under the hood.
- 32:31It's open source, it's well-documented.
- 32:33I have a few peer-reviewed articles about the exact process.
- 32:36So we don't all have to reinvent the wheel
- 32:38trying to work with this data
- 32:39because none of this is automatic.
- 32:41And in fact, 10 plus years ago,
- 32:43People were very laboriously having to write
- 32:46these long scripts.
- 32:47- You know what I'm gonna do?
- 32:48I'm gonna get a grad student
- 32:50and it's gonna be their job for the summer
- 32:52to convert this to Excel or MATLAB for me.
- 32:55Something like that.
- 32:56- Yeah, exactly, yeah.
- 32:57Grad students are great.
- 32:59But what's much greater, I think,
- 33:01is having one or two lines of code
- 33:02to replace your grad student for the summer.
- 33:04- 100%, let them do meaningful work
- 33:06that they also like, right?
- 33:07- Yeah, that's the whole--
- 33:08- Find it out.
- 33:09Yeah, yeah, that's fantastic.
- 33:10As I look at this and think about this,
- 33:12It feels to me like OSM and X is a little bit like an ORM is to SQL and databases.
- 33:20Right?
- 33:20Like, let's you, you think more in Python language and concepts and don't
- 33:26worry about the query syntax and the data and all that kind of stuff.
- 33:29Is that a reasonable analogy?
- 33:31>> Yeah, that's a good way to put it.
- 33:32And, and the goal for doing something like that is to try to democratize
- 33:37doing some of these analyses.
- 33:39You know, open street map data are really amazing.
- 33:41Overpass is an amazing resource,
- 33:43but it's really hard to work with
- 33:45unless you have some software development
- 33:48or database experience.
- 33:50And a lot of urban planners or urban geographers
- 33:52or urban sociologists do not.
- 33:55They have great questions, they have great theory,
- 33:57they want a hypothesis test, right?
- 33:59But we limit science if our tools are too difficult to use
- 34:03or the right data are too hard to access.
- 34:06- Yeah, back to that basic science ideas, right?
- 34:09- Yeah.
- 34:10- Yeah, so for something like this, what OSMNX does
- 34:14is it puts that kind of overpatch query
- 34:16into much more natural language.
- 34:17Since Python is so readable in the first place,
- 34:20you can just say something like graph from place,
- 34:23give it a city name, say Pasadena, California.
- 34:27My network type will be drive, and then just like that,
- 34:31I have that drivable street network model
- 34:34within the city limits of Pasadena.
- 34:36- Right, yeah, that sounds entirely more usable.
- 34:39- And one of the things you said is that it's,
- 34:42it can be pretty expensive to query the Overpass API,
- 34:45and so your library caches that stuff locally, right?
- 34:48- That's right, yeah, so expense in the computational sense,
- 34:52all these things are free to use.
- 34:55- That's what I mean, computationally expensive.
- 34:56- Yeah, exactly, and there's a lot of time complexity
- 34:59to it as well.
- 35:01So what we do is we cache everything,
- 35:04which helps you avoid rate limiting.
- 35:05let's OSMNX be a good neighbor
- 35:08to these free public commons resources that are out there.
- 35:12- Yeah, interesting.
- 35:13It sounds almost like you could have a Docker containers
- 35:16for different cities that are preloaded
- 35:19with all the data that might be interesting
- 35:21to just instantaneously answer a bunch of questions.
- 35:24- Yeah, which is really my work.
- 35:26So a lot of what I do will be,
- 35:29I study every street network
- 35:30for every urbanized area in the world, right?
- 35:33So we'll have like eight to 9,000
- 35:34of these large urban models.
- 35:38And so I'll just have things cached locally
- 35:40so that the model building and analytics
- 35:43are really at the forefront
- 35:44rather than the downloading and querying for a day.
- 35:47- Right, it's not only lets you be a good citizen
- 35:49and not hammer on OpenStreetMaps API,
- 35:52but it just lets your stuff work faster.
- 35:54So the incentives are aligned there, right?
- 35:57- Yeah, and in fact, a lot of the time
- 35:58when people first use OSMNX,
- 36:00you know, you'll download the, say the model of Los Angeles, California,
- 36:05and it takes a minute to run the query on their server, download whatever,
- 36:09a hundred megabytes of data, and then build that graph,
- 36:14theoretic model, do all the spatial stuff to it. but after that,
- 36:18it's nice and fast the next time that you do it,
- 36:20because you're able to skip all of that pre-processing from the cache.
- 36:23It probably puts it into some super efficient data structure.
- 36:29or some others, maybe dictionaries, who knows, right?
- 36:31- Yeah, yeah, and we use spatial indexes
- 36:35to accelerate all of the spatial queries locally too,
- 36:39as well.
- 36:40- Is that built into Geopandas?
- 36:42- Yeah, built into Geopandas, there is an R tree,
- 36:45which is probably the most common spatial index.
- 36:48But in addition to that, we also use SciPy's KD tree.
- 36:54They have like a C implementation of a K dimensional tree
- 36:57that we can do nearest neighbor search.
- 37:00So for example, Google Maps,
- 37:01you say from my origin to my destination,
- 37:03we can do the same kind of thing.
- 37:04Say from this point to that point,
- 37:06we'll snap the nearest neighbor on the network
- 37:08and then solve a path between them.
- 37:10- Okay, so just the k-nearest neighbor algorithm
- 37:13sort of applied to, what is that,
- 37:15the vectors of the intersections or something?
- 37:19Or then you--
- 37:20- Yeah, so normally when you do origins and destinations,
- 37:23you would snap to a node in the network.
- 37:25So the nodes would be like the intersections and dead ends.
- 37:28And then the edges would be the links,
- 37:30the street segments that connect everything together.
- 37:33And when you solve a path on a graph,
- 37:37it would be from a start node to an end node.
- 37:41Then you'd minimize it by something,
- 37:43either the fewest hops or the shortest distance
- 37:46or the shortest travel time.
- 37:47If you incorporate, say, speed limits, everything else,
- 37:49you can bring in congestion information
- 37:51to minimize traffic congested travel time
- 37:54or minimize going up and down hills or anything else.
- 37:58- Excellent.
- 37:58If I got this data downloaded
- 38:01and I wanted to put it into a proper database,
- 38:04and by proper I mean one that is its own process,
- 38:07different machines can talk to it in parallel and whatever,
- 38:09you know, like Postgres or Mongo or something,
- 38:12are there good databases that you would recommend
- 38:14or that you've tried, like EdgeDB or Neo4j
- 38:17or graph databases the right way to go,
- 38:19or what do you think?
- 38:20- It depends on what you're trying to do
- 38:23In terms of OpenStreetMap features,
- 38:25so if you're just downloading features
- 38:26and you're not worried about,
- 38:27you say those topological relationships between things,
- 38:30like in a street network,
- 38:31any tabular data structure will do.
- 38:36Any kind of like SQL database will do just fine.
- 38:39For a graph model,
- 38:41yeah, you'd want some kind of graph database
- 38:43because they can handle graph algorithms
- 38:46to do stuff like routing
- 38:48or other kinds of graph analytics
- 38:49like understanding connectivity on the network.
- 38:52- Yeah, I have this, given this node,
- 38:54tell me all the things that are connected to it.
- 38:56Like that, those kind of questions
- 38:57could be answered. - Yeah, those kind
- 38:58of questions, yeah. - Right, yeah.
- 38:59Yeah, they're kind of pre-computed by the indices
- 39:02in the structures.
- 39:03What about bringing in other data?
- 39:06You know, what if I have real estate data
- 39:08that doesn't come from OpenStreetMap,
- 39:10but I want to pull that in and overlay it
- 39:13with, say, zoning information,
- 39:15overlapped with census data that gives me revenue,
- 39:18you know, how much that person in that area
- 39:21makes per year on average or something like that.
- 39:23Can you answer questions like that?
- 39:25- Yeah, really common use case.
- 39:26So OSMNX can kind of do that by itself,
- 39:29but mostly as a tool in the toolkit to do it.
- 39:32So, you know, a common way that we often will do this
- 39:35is for accessibility analyses.
- 39:37So for example, here at my house,
- 39:39how many grocery stores could I access
- 39:42within a 15 minute walk?
- 39:44And it gives you a sense of, you know,
- 39:46how car dependent or not a place is.
- 39:48And also we can start looking at food deserts
- 39:51communities where people don't have access to fresh food.
- 39:53So for that, what you're doing is you have a model of the network, and then you also
- 39:57have all of this point of interest data, right?
- 39:59So where all these amenities are located, you would then snap them, load them onto
- 40:04the graph, and then you can calculate accessibility by looking at where those
- 40:08things are located.
- 40:09And you can either look at cumulative opportunities within some time horizon or
- 40:14distance to the nearest opportunity.
- 40:16You can put different decays on it, like the utility of it being so far away, drops
- 40:21the linear decay the further I have to go
- 40:23or a non-linear decay if it really drops off fast.
- 40:26But it's exactly that.
- 40:27- Yeah, if a grocery store is three miles away,
- 40:29it's not one third as useful as one that's one mile away.
- 40:32It's a little bit more to carry your groceries that far.
- 40:35- And similarly, there's marginal utility
- 40:37for the 30th grocery store that you can reach.
- 40:40Doesn't give you that much benefit
- 40:41over the 29th that you can reach.
- 40:43Whereas the first and second are very valuable.
- 40:46- Yeah, if it goes from zero to one and one to two,
- 40:48those are big jumps right there.
- 40:50- Yep.
- 40:50- Okay, very interesting.
- 40:52How about some projects that people might be thinking about?
- 40:57They look at this data and they're like,
- 40:58"Wow, this looks really detailed and neat,
- 41:00"and we have all these different aspects we can ask about,"
- 41:03but maybe they just wanna play around.
- 41:06- Yeah, I mean, hopefully,
- 41:08if you look at the Getting Started Guide
- 41:10or these usage examples,
- 41:11you'll see it's really easy to play around,
- 41:13two, three lines of code,
- 41:14and you have a visualization of your local street network.
- 41:18things that we've done in my lab at USC that may spark some interest. We look at
- 41:24air pollution exposure and driving patterns in Los Angeles to try to
- 41:28understand you know who's driving and where and then in turn who is exposed to
- 41:33that tailpipe, those tailpipe emissions from those cars. So we use OSM and X to
- 41:39model those street networks to simulate those trips and to look at what census
- 41:44tracks that stuff goes through. We also use it for studies of urban form. So that is kind
- 41:50of the shape, texture, density, the grain of a city. I have this series of square mile
- 41:57visualizations of different cities around the world. And you can really quickly see
- 42:01how different forms of urbanism look relative to each other. So a place like Irvine, California,
- 42:10in Southern California has this really coarse-grained street network.
- 42:15A place like Venice in Italy has incredibly fine-grained, like spiderweb street network.
- 42:22Stuff like that really helps to kind of convey these different modes of urbanism and urbanization.
- 42:28We also use these to look at disaster resilience.
- 42:32That is, different street networks will be better if things start going wrong around
- 42:37Things with more redundancy, more connectivity built in
- 42:40are easier to route around if parts start failing
- 42:43in a fire, in an earthquake.
- 42:45And so we can capture some of these characteristics
- 42:47and then make recommendations to planners and policy makers
- 42:50about how to make your street network,
- 42:52how to intervene in it to make it more resilient.
- 42:54- Yeah, in my area, there's an East-West highway,
- 42:57one of them, very few, that goes from the city west.
- 43:01It has to go through this mountain tunnel
- 43:03and it's two lanes each way in the mountain,
- 43:05or three lanes in the mountain tunnel.
- 43:06and there's even on a Saturday afternoon,
- 43:09there's stopped cars trying to go through that tunnel.
- 43:12And those are on good days.
- 43:13Imagine if there was an emergency, it would just be done.
- 43:16- Yeah, that's the 26, right?
- 43:18- Exactly, it is the 26.
- 43:20- Yeah, I used to live in Portland.
- 43:22I lived in Goose Hollow, and my gym was in Beaverton,
- 43:27so I would have to go through that tunnel to go work out.
- 43:30It would always be like, you know, one of these days,
- 43:33one of these days.
- 43:35- Exactly, yeah, I live about a mile from Goose Hollow
- 43:38up through that tunnel.
- 43:39So yeah. - Oh, cool.
- 43:40- Yeah, yeah, very cool.
- 43:41Yeah, but there's just, and that one's hard to fix
- 43:43because there's houses all along there.
- 43:45It's a big hill, hard to go over it.
- 43:48You know, it would take a lot of willpower
- 43:50to make another tunnel.
- 43:51- Yeah, interesting thing.
- 43:52I did my PhD at Berkeley,
- 43:54and there is another tunnel there
- 43:56that goes from that kind of inner East Bay,
- 43:59Berkeley, Oakland border,
- 44:00out to the further East suburbs
- 44:02like Orinda, Moraga, and so forth.
- 44:05And that tunnel is really old.
- 44:07I mean, it's, I don't know, 80 years old,
- 44:09maybe something like that.
- 44:10And they determined that when the big one
- 44:12does eventually hit, it will fail, it will collapse.
- 44:16And it's not, it's cost prohibitive
- 44:19to actually prevent that from happening.
- 44:20So the idea is it will collapse
- 44:22and crush everyone in that tunnel,
- 44:24and they will then build a new tunnel
- 44:26at that point when they have to.
- 44:27- Oh my goodness.
- 44:28- We have a lot of that to look forward to.
- 44:29(laughing)
- 44:31- Yeah, just go quickly when you're in the tunnel.
- 44:33Get out of there.
- 44:34>> I always did.
- 44:35>> Amazing.
- 44:38All right.
- 44:39Let's talk real quickly about integrating OpenOSMNX with other data science tooling,
- 44:47right?
- 44:47We have so many different things.
- 44:48We have PyTorch, we have Pandas, we have Polluters, all the different things.
- 44:54Like what are the different integration features?
- 44:56You know, you talked about data frames.
- 44:57That sounds like Pandas and GeoPandas, right?
- 45:01That's one sort of path across those things.
- 45:03- Yeah, so OSMNX is built primarily on top of three things.
- 45:10It's NetworkX for the graph models,
- 45:14Geopandas for the spatial data frames,
- 45:17and Matplotlib for the visualizations.
- 45:21In the spatial Python world,
- 45:24most stuff happens in the pandas ecosystem
- 45:28because Geopandas and PySAL and similar tools
- 45:31are very pandas-oriented.
- 45:34I know there's been some work toward geopolars,
- 45:37but it's kind of in its infancy,
- 45:39as far as I know, to this extent.
- 45:41But that'll be great when that's available.
- 45:44NetworkX is another funny one
- 45:45because it's a pure Python implementation.
- 45:49It has a lot of loops,
- 45:49and so it can go really slow for calculating
- 45:52some of these big time complexity graph algorithms,
- 45:56things like betweenness centrality,
- 45:58where you have this massive OD native,
- 46:01basically all the nodes to all the nodes.
- 46:03- Yeah, yeah, some combinatorial craziness.
- 46:06- It ends up being very time consuming
- 46:08to calculate those kinds of things
- 46:10for a metro area sized network model.
- 46:14So we'll integrate with other tools.
- 46:17iGraph does that in C.
- 46:20Also using tools like QGraph
- 46:23where you can do it on the GPU instead
- 46:25can be really fun. - Oh wow, okay, yeah.
- 46:27- But it's limited because of the weighting scheme
- 46:31that you say, I want to minimize travel time
- 46:34or stuff like that.
- 46:35- I see.
- 46:37- Yeah, and then also integrated with Folium
- 46:41to create interactive leaflet web maps out of the box.
- 46:46- Yeah, I wonder how that the free-threaded Python stuff
- 46:50will affect some of those computational things.
- 46:52Like that everything compared with everything else
- 46:54sounds like a so-called embarrassingly parallel
- 46:58sort of problem, right?
- 46:59And so, you have 10 cores, so let's just do 10 blocks
- 47:04of them all in parallel and you know.
- 47:06- Yeah, so that's what we do when we do it in pure Python.
- 47:09So we'll use multi-processing generally with all your CPUs.
- 47:14The only challenge is that your OD matrix,
- 47:18your origin destination matrix is growing
- 47:20at this exponential rate, but then there's a linear number
- 47:23of cores, so going from one to 24,
- 47:25you're dividing by a factor of 24.
- 47:27But when you have say a million nodes
- 47:30times a million nodes in your graph,
- 47:32it's going to take a long time.
- 47:34- It's still gonna be slow, but it's--
- 47:36- You've got from months down to weeks.
- 47:39- Yeah, I mean, you're still dividing it
- 47:41by the number of cores,
- 47:42but it doesn't necessarily mean it's super fast.
- 47:45Although the GPU stuff seems like
- 47:46it could absolutely fly, right?
- 47:48- Yeah, that makes a big difference.
- 47:50And I think that's really the area of growth
- 47:53where the handling, I mean, basically getting out
- 47:55of Python loops in the first place
- 47:57is the biggest area of growth.
- 47:59And then doing things on a,
- 48:01since these are really just
- 48:02very simple linear algebra problems,
- 48:04being able to do them on a GPU
- 48:06makes it much more efficient.
- 48:07- Yeah, did you hear about this thing,
- 48:10this new NVIDIA, what, I don't know what it's called,
- 48:12Project Digits, where they announced
- 48:14a $3,000 desktop AI computer?
- 48:18I mean, they call it AI, but really it's just a GPU.
- 48:20- That is, no, I hadn't heard about that.
- 48:22- And this thing, it's the size of a Mac mini.
- 48:25It's this, if you look at the pictures,
- 48:27a little bit of a golden thing.
- 48:28It's kind of clever they made it gold,
- 48:30but that's a massive computer sitting next to you.
- 48:35- Yeah.
- 48:36- You could run that.
- 48:36This is pretty interesting actually, I think.
- 48:39- Yeah, yeah, that is.
- 48:42I mean, it's shocking too,
- 48:43because it looks so much smaller
- 48:44than just an Nvidia card in your desktop.
- 48:49- I think it basically is just the GPU.
- 48:52- Right.
- 48:52- Nothing to do with graphics.
- 48:53just remote into it over, I don't know, a terminal or however you, or maybe you set
- 48:58it as the Docker host and then you just do Docker locally, but it runs there, you know,
- 49:02that type of thing.
- 49:03I don't know how it works, but I kind of want one.
- 49:05>> Yeah.
- 49:07I mean, it looks sexy enough.
- 49:08Of course you would want one, right?
- 49:09>> Of course.
- 49:10But if you had questions like that, if you say I have a million nodes and I could run
- 49:13that on a GPU, getting something like this that's, you know, kind of the H100 style of
- 49:18like the really large just meant for compute, not really a graphics card.
- 49:23like that would really unlock some interesting options.
- 49:25Yeah, totally.
- 49:26I mean, yeah.
- 49:27So I have a, a GeForce card in my desktop that I'll pass
- 49:32them and that stuff locally onto.
- 49:33But, another one of the academic benefits at USC, we have a high
- 49:37performance computing cluster that, I can schedule tasks to run on that,
- 49:43say over winter break and then come back in January and, and the month
- 49:47of, of, 1000 CPUs is all done.
- 49:51That's amazing.
- 49:52And we had a mainframe, a silicon graphics mainframe
- 49:57when I was studying math that we could all work on
- 50:00in this group of maybe 10 of us.
- 50:02And it wasn't as big as what you're saying,
- 50:04but it was a quite expensive, big machine.
- 50:07It had its own room and it was really allowed
- 50:09to go into that room.
- 50:10And I remember we came in to,
- 50:12I came in to do whatever I was working on
- 50:14as a grad student or whatever, I think I was a senior.
- 50:17Anyway, I came in to work on my project
- 50:20and nobody could access it.
- 50:21and it was still in there making loud noises
- 50:23like it was running, but it acted like it wasn't running.
- 50:25And so I'm like, what is going on?
- 50:27One of the other grad students had run a job
- 50:29like you're talking about,
- 50:30but they were having trouble getting into work
- 50:32'cause they were math people, not programmers.
- 50:34And they started logging everything.
- 50:36And there were no limits on what people could do
- 50:39to the computer, the people that set it up.
- 50:41And so what had happened is it ran 100% CPU
- 50:45on all the cores all night logging
- 50:46until it ran out of space.
- 50:47And then apparently the computer won't run anymore
- 50:49if it has zero more bytes.
- 50:50needed some temp file or something.
- 50:52And so it just, it was just done.
- 50:55I imagine you guys have more guardrails than that.
- 50:59- Yeah, a lot of guardrails.
- 51:00I would love to try to do something like that
- 51:03just for the yuck sometime, but we got a lot of-
- 51:06- The admins of that computer
- 51:09would not please with that grad student.
- 51:10- I can only imagine.
- 51:12- It took a long time to get it going.
- 51:14It's like a day of work to get it turned back on.
- 51:16'Cause they didn't even know what was wrong with it at first
- 51:18it just wouldn't turn on.
- 51:19- Oh well, jumping back a moment to the,
- 51:23no, that's not the one I wanted to copy,
- 51:25to the integration, have you considered
- 51:28working with narwhals?
- 51:30- I looked into narwhals recently.
- 51:32My understanding is one of the things that does well
- 51:35is it kind of abstracts away from pandas versus polars,
- 51:38so you're less tool dependent, right?
- 51:40- Yeah, and it also lets people
- 51:42who want to consume your library,
- 51:44who want to do their work in polars,
- 51:46talk polars to your project,
- 51:47and people want to do pandas, talk pandas,
- 51:50as well as QDF, modem, pyro, and other.
- 51:53It kind of is an adapting layer,
- 51:56so people can work in their native framework
- 51:58and then talk to you.
- 51:59- Yeah, I mean, yeah, on paper it sounds great.
- 52:02I haven't played with it yet,
- 52:03other than just being familiar with it,
- 52:04but I mean, that sounds like the ideal, right?
- 52:07We shouldn't be enforcing these certain APIs
- 52:10or languages on people.
- 52:11- Yeah, it does look interesting.
- 52:12I believe its foundational internals are maybe just the API,
- 52:16But there are Polars, not pandas,
- 52:19so maybe that's not as good of a fit.
- 52:20But it could be an interesting thing to look in the future to
- 52:24make it native to
- 52:25all the different DataFrame libraries that people want to talk in.
- 52:28>> Yeah, definitely.
- 52:30>> Are you going to need a new grant?
- 52:31>> Yeah. Here's the basic science stuff.
- 52:34If I'm interested in network models,
- 52:36I don't know about getting into the nuts and bolts of
- 52:39which DataFrame API we're going to have people use.
- 52:43- Yeah, yeah, absolutely.
- 52:47All right, well, let's close this whole conversation out
- 52:51by talking about something that I know
- 52:53is on a lot of people's minds, and that's LLMs.
- 52:56And what do LLMs mean for this mapping data
- 53:01and the types of questions you can answer
- 53:02in OSMNx, all these types of things?
- 53:05Like, how's that shaping your world?
- 53:08- Yeah, so two ways that I like to think about it.
- 53:11One is what LLMs have to offer us today.
- 53:14And then one is what LLMs have to offer us,
- 53:17say five to 10 years from now.
- 53:18That is, how do we future-proof ourselves,
- 53:21our careers, our livelihoods?
- 53:23And I mean, or just optimistically,
- 53:25how do we really get ahead of it to take advantage
- 53:28of nice things that they'll have to offer?
- 53:30Today, I am deeply unimpressed with most of the use cases
- 53:34that I see for it.
- 53:36I think that the outputs only look good
- 53:38to people who aren't experts
- 53:40and don't know how wrong it is.
- 53:42Does some things well, you know,
- 53:43like having a co-pilot while you're coding
- 53:45and having it recommending.
- 53:47That's nice.
- 53:47I mean, it's like tab complete from years ago.
- 53:49It's the same kind of thing, just iterating.
- 53:52But you know, when someone tells it to,
- 53:55you know, here's the prompt,
- 53:56generate my algorithm for me.
- 53:58Two things.
- 53:59One, it very often doesn't do that good of a job
- 54:01even at this point.
- 54:02And number two, if you don't enjoy doing that kind of thing,
- 54:06I'm not sure why you're in software development
- 54:09in the first place.
- 54:10- I know.
- 54:10- For me, when I interface with it,
- 54:12it's usually in the classroom.
- 54:14And you'll have, so, you know,
- 54:16people like to complain kids these days.
- 54:17It's the same way it was when I was in school.
- 54:19You know, a third of the class loves a subject.
- 54:22They're just killing it.
- 54:23They wanna be there.
- 54:24They want a job in this.
- 54:25A third of the class, they're like,
- 54:27"Well, it's a required class.
- 54:28"I'll try to do what I can."
- 54:29And a third of them say, "I don't know why I'm here.
- 54:31"Why is this a required course?
- 54:33"I hate this.
- 54:34"Is there any way I can cheat
- 54:35"to just get a passing grade?"
- 54:37- Where's my shortcut?
- 54:38- Exactly.
- 54:39I mean, and you know, the difference today
- 54:42is that LLMs make it so much easier
- 54:44and they really normalized cheating as well,
- 54:47where we don't have that good of systems in place
- 54:50to be able to detect it for code,
- 54:53for writing, for anything.
- 54:55And I think one of the problems here,
- 54:57you know, it goes back to like licensing or attribution.
- 55:01When we normalize this kind of cheating,
- 55:03we're normalizing taking credit
- 55:05for things that aren't our work.
- 55:07And if we're doing that in school, we build those habits,
- 55:09what's it gonna look like
- 55:10when we're working in the workforce?
- 55:12We either don't have the skills that people think we have,
- 55:15or we think it's just normal, acceptable practice
- 55:18to copy and paste and say,
- 55:20here's my intellectual contribution.
- 55:22- It's too much of a crutch,
- 55:24and if maybe it solves 90% of the problems,
- 55:26but that 10%, it doesn't,
- 55:28you're fully incapable of approaching that problem, right?
- 55:31- Exactly, yeah.
- 55:32And I think, so that's the first part,
- 55:34what LLM's offered us today.
- 55:35I think the second part is say five to 10 years from now.
- 55:39Part of it is scary and part of it is exciting.
- 55:41I think that coding as it looks today
- 55:44is going to largely go away over my lifetime
- 55:48because coding is this mix of art and intellectual labor
- 55:52and manual labor.
- 55:54The manual labor parts will be going away
- 55:57and that's where a lot of people use LLMs now
- 55:59to reduce some of that grind of coding.
- 56:02And I think it's important for us to figure out
- 56:05where those intellectual contributions are,
- 56:07where the art, the poetry of coding
- 56:10remains a human contribution moving forward,
- 56:13where we have that sort of human in the loop
- 56:16to make ethical decisions that we don't pass off,
- 56:19where it is humans who are doing some of the architecting
- 56:21and not just handing it off saying,
- 56:23"Here's a prompt, now redesign our financial system
- 56:26from the ground up for us,"
- 56:27but that it remains human guardrails and human ethics
- 56:31and human notions of justice that we use AI to help us,
- 56:37but doesn't replace that.
- 56:38- Yeah, I feel like there's gonna be a lot of people
- 56:41who are programmers now are gonna have to kind of be
- 56:43a senior tech team lead type of thing,
- 56:47where the team is asking the LLM to do stuff for you.
- 56:50And that's gonna be awesome for those people, us,
- 56:53but for the people who are brand new,
- 56:55there's gonna be a wider gap to try to cross.
- 56:58It's gonna be harder and harder to go from real beginner
- 57:00to that level when, who's going to employ you
- 57:04when it takes you a day and I can ask the LLM
- 57:07to do it in five minutes and I got to review it either way.
- 57:09That's a very concerning social consequence, I think.
- 57:13- No, exactly.
- 57:13I think those kind of entry-level jobs
- 57:17are very much more labor-focused, right?
- 57:20The senior dev isn't doing that work
- 57:23because someone with less experience, less pay can do it.
- 57:27And if LLMs replace that over time,
- 57:29It's really hard to get your foot in the door in that industry.
- 57:31- Yeah, it can be like COBOL programmers
- 57:33did not a program without an LLM someday.
- 57:35(laughing)
- 57:36- Yeah.
- 57:37(laughing)
- 57:38- I don't know if that's good or bad,
- 57:39but it's gonna be weird.
- 57:40Anyway, I think it's probably pretty interesting.
- 57:44And given, you know, access with your API
- 57:46and with all this data,
- 57:47I'm sure people will be able to ask
- 57:49and answer interesting questions with it.
- 57:51- That's the hope.
- 57:52- Indeed, all right.
- 57:53Two really quick things to close out our conversation.
- 57:55Roadmap, anything on the roadmap coming real soon
- 57:58that people have been asking about, thinking about?
- 58:01- Yeah, so I just released V 2.0,
- 58:06I don't know, a month or so ago.
- 58:08And so, thank you.
- 58:09And that was really just a year of rethinking the API.
- 58:14I was gonna allow myself breaking changes,
- 58:16really cleaning things up.
- 58:17I added type annotations for the first time.
- 58:19I really changed the linting and formatting,
- 58:23CI, pre-commit, everything.
- 58:24So it's a much more rigorous package at this point.
- 58:28I'm taking a breather right now,
- 58:31where I don't have that much big on the horizon.
- 58:34I try to keep a really clean issue board as well,
- 58:37where I quickly triage, this is in scope, this is not.
- 58:40- Yeah, I noticed you have three open issues
- 58:42and zero PRs, which is awesome.
- 58:43- Yeah, I try to do it courteously,
- 58:45where I'll tell people a lot of the time,
- 58:47you know, this isn't in scope for the project,
- 58:48but I appreciate the suggestion, but I'm busy,
- 58:51so keeping a clean issue board makes my life simple.
- 58:53So short answer, I'm taking a breather
- 58:56instead of road mapping in January.
- 58:59- But you just had a big release, which is cool.
- 59:01- Yeah.
- 59:01- Yeah.
- 59:02Contributions accepted?
- 59:04- Absolutely.
- 59:04And very often what I ask when someone opens an issue
- 59:08and I say, "Yeah, that does sound useful,
- 59:10would you like to open a PR?"
- 59:14And as much as this is my side hustle,
- 59:16most of the pull requests that I add to it
- 59:19are very much aligned with a current
- 59:21or recent research project that I'm working on.
- 59:24So for others, if you see a gap or a cool feature
- 59:28that could make people's lives easier,
- 59:30better analytics down the road,
- 59:31please propose it and I'd love a contribution.
- 59:34- Excellent.
- 59:34All right, final call to action.
- 59:35People are psyched about mapping.
- 59:38They wanna get started.
- 59:38What do you tell 'em?
- 59:40- I tell them to work through existing examples
- 59:44from the tools that are out there.
- 59:45If you haven't done any kind of mapping before,
- 59:47there's a lot of cool packages in R and in Python.
- 59:51Find something you're comfortable with.
- 59:53work through some tutorials,
- 59:54and then figure out something close to home.
- 59:56It's so much easier if you have that kind of
- 59:59local motivation, local knowledge.
- 1:00:01Do some mapping, do an analysis in your community
- 1:00:03for something that's bothering you,
- 1:00:04you know, you think could be better.
- 1:00:06- Excellent.
- 1:00:07All right, well, thank you for being here
- 1:00:08and congrats on that cool project.
- 1:00:10- Thank you very much.
- 1:00:12- This has been another episode of Talk Python To Me.
- 1:00:15Thank you to our sponsors.
- 1:00:17Be sure to check out what they're offering.
- 1:00:18It really helps support the show.
- 1:00:20This episode is sponsored by Posit Connect from the makers of Shiny.
- 1:00:25Publish, share, and deploy all of your data projects that you're creating using Python.
- 1:00:29Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs.
- 1:00:36Posit Connect supports all of them.
- 1:00:38Try Posit Connect for free by going to talkpython.fm/posit.
- 1:00:42P-O-S-I-T.
- 1:00:44Want to level up your Python?
- 1:00:45We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:00:50Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:00:55And best of all, there's not a subscription in sight.
- 1:00:57Check it out for yourself at training.talkpython.fm.
- 1:01:00Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:01:05We should be right at the top.
- 1:01:06You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the Direct
- 1:01:12RSS feed at /rss on talkpython.fm.
- 1:01:16We're live streaming most of our recordings these days.
- 1:01:19If you want to be part of the show and have your comments featured on the air, be sure
- 1:01:22to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:01:27This is your host Michael Kennedy.
- 1:01:29Thanks so much for listening.
- 1:01:30I really appreciate it.
- 1:01:31Now get out there and write some Python code.