Geography of the Study of Places and Relationships Between People and Their Environments.
Often we think of maps, but maps are static.
GIS gets interesting when you realize that we're studying and visualizing data
flowing through these locations and communities.
In this episode, you'll meet Silas Toms.
He's an author of several Python GIS books and the co-host of the Mapist Hour podcast.
Are you ready to dive into GIS with Python?
This is Talk Python to Me, episode 295, recorded October 27th, 2020.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the
ecosystem, and the personalities.
This is your host, Michael Kennedy.
Follow me on Twitter where I'm @mkennedy, and keep up with the show and listen to past
episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
This episode is brought to you by Linode and Talk Python Training.
Please check out the offers during their segments.
It really helps support the show.
At Talk Python, we run a bunch of web apps and web APIs.
These power the training courses as well as the mobile apps on iOS and Android.
If I had to build these from scratch again today, there's no doubt which framework I would
use.
It's FastAPI.
To me, FastAPI is the embodiment of modern Python and modern APIs.
You have beautiful usage of type annotations.
You have model binding and validation with Pydantic.
And you have first-class async and await support.
If you're building or rebuilding a web app, you owe it to yourself to check out our newest
course, Modern APIs with FastAPI over at Talk Python Training.
This is the first course in a series we're building on FastAPI.
And for just $39, it'll take you from interested to production with FastAPI.
To learn more and get started today, just visit talkpython.fm/fastapi or click the link
in your podcast player show notes.
Silas, welcome to Talk Python and me.
Oh, thank you so much for having me, Michael.
Yeah, it's great to have you.
Since this is a GIS episode, where are you calling in from?
Where are you located?
I'm in San Francisco, where I've lived for the last 13 years now, since I moved down for
grad school.
Oh, right on.
I grew up in Northern California, kind of in the middle of nowhere, but I always really
enjoyed this city and I've come to really love it.
Yeah, it's a neat place.
If you were to jump on I-5, the north-south major highway for people who don't know, and
go north for a very long time until the next big city you hit, you'd get to Portland,
where I am, so right on.
You know, I think Ashland's a big city.
You know, Ashland is nice to visit.
Yeah.
But if you could throw a rock across it, it's not a big city.
Yeah, there you go.
Yeah.
You can only have so much Shakespeare in your life.
Yeah.
Yeah, that's right.
That's right.
We're going to talk about GIS and Python and all those sorts of things, but a bunch of
cool job experiences that you've had, as well as some of the libraries and applications and
whatnot.
Well, let's start with the beginning.
How'd you get into programming in Python?
It was kind of a circuitous route.
I mean, my parents, of all things, were organic farmers up in the middle of nowhere when I was
born in Northern Humboldt County.
And my dad had always kind of had an interest in technology.
He wasn't averse or anything.
So when I was about eight, he got a little computer that was programmable that had a
basic program on it.
And so he used that to keep track of sales at our fruit stand.
Oh, right on.
And he taught me how to...
Yeah, it was cute.
And probably 800 lines or something, which seemed amazing to me.
Because he taught me how to do a little bit and I would do little silly things when I was
seven years old or whatever.
You know what's interesting about code is it's not always about how big or how complex it is.
Sometimes it's about what it empowers or the problem that it solves.
Like I can think of a couple of libraries and it's like, gosh, this is so nice this exists.
And it's like a hundred lines of code.
Yeah.
But I just love that it exists, you know?
Completely.
Like we'll get into it.
But like PyShape, it's an implementation reading shapefiles for geospatial data to format.
And it's relatively simple, compact, and it's beautiful.
I love it.
Yeah, for sure.
Okay.
So you had this experience with this basic app that was running the family business?
Yeah.
Well, there was that.
And then in high school, around 97, I took an elective in computer programming, also basic,
which I didn't like love the other crowd in the room, really.
I was always thinking of myself as a little more active.
I played sports, but I did like it.
I just, I couldn't fully identify with it.
And being from like a rural kind of macho county, like it just didn't occur to me that
that was something I could do.
And if you could see the future, like...
Yeah, yeah.
Now all the cool stuff you can build and like how sort of tech has changed in perception,
right?
Who knows?
Maybe it would have...
Well, maybe if I could just read the newspaper, because at that time, it was like the first dot-com
wave.
And I just wasn't really in the mindset that that was something I would do with my career.
But I went to college.
I went to Santa Cruz, and then I was kind of homesick.
I finished up back at Humboldt State University and got really into geography, which is a really
interesting quasi-science, I guess you'd say, that has a lot of really interesting theories
about why the world is, how it's divided up and why it's divided up the way it is.
How people sort of present themselves across space, how cultures interact with the physical
sciences.
And somebody who like spent my whole childhood like reading through encyclopedias, it was just
the best combination of learning and interests that I could ever find.
So without even realizing it, I had never heard of geography before I really got into college.
It was amazing.
It was perfect for me.
And it had this component that was, I think, a bit too lightly touched on called GIS, geospatial
information systems that I got exposed to.
And I thought it was kind of cool, but I wasn't, again, expecting to make computers a part of my
professional career at that time.
I was really focusing on environmental policy and water policy, especially.
Humboldt County has a lot more rain than the rest of California, and they've built these
giant dam systems to bring it down to the Central Valley.
And it seemed like there was a huge fish die-offs in 2001, 2002 that were directly attributed
to the lack of water.
And so I got kind of interested in like, how did they make these decisions to build these
dams?
Why does this water policy exist?
How did they benefit and value agriculture, like sort of profit or cotton that wasn't really
making a profit in the Central Valley versus salmon, which could be very valuable where I
was from.
So I got really deep into those weeds and ended up going into grad school in San Francisco
State for geography with a focus on resource management.
And that was 2007.
Nice.
And did you end up with like a lot of data?
Do you need a process?
You're like, all right, I guess I'm going to have to take out these computers again.
I just remember like late nights trying to figure out, like just really struggling with
the software and doing some interesting.
Also, another interest of mine was wine.
And I remember trying to do like a temperature map of Humboldt County because a lot of the
organic farming families that I'd grown up with had started growing wine at the time.
And I wanted to see like, how does it compare temperature-wise to Napa Valley or to other well-known
places?
And I just hated the manual data entry that I was doing.
And I thought, there's got to be a better way.
So those feelings and a couple internships that I got when I got to grad school really
led me to value programming.
And I felt so stupid with it at first because even though I'd had that experience as a child,
it had been a decade since I'd really touched a keyboard that way.
And I felt like there's got to be something to this.
So I'll just keep hitting my head against the wall.
And even though I feel kind of dumb, I know that I can use this.
And it really worked out.
Yeah, that's super cool.
I think it's really interesting in your story about how you kind of like slowly just dragged
you in.
And then you're like, fine, fine, you've got me.
I kind of went down the same path as you in some regards in that I didn't really see myself
as a developer.
I kept looking to do other things, chemistry and math and so on.
And eventually I just like, you know what?
Actually, I do like this better, but it's easy to forget those early days of like fighting
with the syntax.
Just, yeah, I remember being so excited about getting a C++ program to compile a little bit
right now.
It's going to have to run and work correctly.
That's the hard part.
Not the compiling, but these early days.
Yeah.
You step over these challenges and then they're kind of in the past.
But yeah, everyone goes through them.
Well, I remember when I was really trying to learn in 2008, I took a class that was sort of
an elective offered through the computer science department.
And I got to be really good friends with the guy who was just a master's in engineering student
himself.
And he really saw that I cared, even though I didn't know anything, basically.
And so he spent some time and taught me a bit of Django at that time, which was just coming
out.
And I remember getting so excited when I was able to have Django use ArcPy, talk to a shapefile,
get a location out and put it on a browser.
Just like a little tiny thing.
Yeah.
I showed my grandmother.
I'm like, grandma, I did it.
She had no idea what I was talking about.
I bet she was really happy to see it though.
She must've been psyched.
She didn't discourage me.
She was so excited.
But I just remember that moment of just like, I did it.
And the wizardry of that.
I still don't think I'm over that, really.
Yeah.
No, I haven't gotten over it either.
It's amazing.
And just that feeling of I built something that could be useful to people and it's out there
and they can play with it and then to see them come and use it is just amazing.
I started just that same process of like, whatever I could do at work.
Because at this point I had gotten a job as a GIS technician.
I was making maps of a park district lands that they were considering adding.
And I found it great to be paid, especially during the recession there.
But I was not like loving the work itself.
So I found all kinds of ways to use Python to automate, to figure out how to make like a database of all the other maps we had made to just anything that I could think of that was interesting to me.
I'm never going to enter a map a second time.
Yeah, exactly.
Stupid map.
So and then somewhere in there, I got a call from a recruiter.
I had some friends of friends who were in the program who knew that I did some Python and they recommended me for a job at an environmental consulting firm called ICF.
And the recruiter, I remember him saying like, do you really want to work for the government?
You know, you're like 27, right?
Yeah, I suppose you're right.
I was so happy to just have a steady job at that point that I wasn't actively looking, but there was some pull to just something different and exciting.
And I really benefited because it brought me into the opportunity to work on big environmental projects like the high-speed rail project and figure out how to use Python to automate those.
Because we were getting engineering outlines in AutoCAD and we had to convert that into GIS formats and then run that against all of the data we had on species range.
Or any kind of protected resource, even like farmland or wetlands or anything like that.
And we had to do it week after week after week.
And I was kind of, I just remember that first call when I first got hired where I was like, I think I can automate this.
Yeah.
With that upward tilt in my voice, but I could.
And I did.
That's awesome.
I kind of became a team.
And they probably saw you, like you said, as a wizard.
They're like, Silas can make it do it automatically.
Do you understand what that means?
On its own, right?
Like not other people.
Yeah.
And some of the libraries we're going to talk about in GIS are like, hey, I've got this lake and I've got this other thing.
Do they intersect?
Or does this line pass through this area?
And really interesting stuff that builds on common libraries that people will know like SQL.
Well, exactly.
You know, the one big one that really got me at that time, because I was running into like licensing issues with the Esri ArcGIS software that we were running, couldn't really do some of the higher level analyses I needed to do.
So I heard about this thing called PostGIS, which was built on top of what is it?
PostgreSQL and then a library called PsychoPG2 that allowed me to write spatial SQL and directly talk to a database and do those analyses in code like I had never been able to do before.
And it kind of blew my mind.
This is around 2010, 11 or something.
That's when I realized like beyond the world of the software that they had given me, this Esri software, there was this incredible open source software community that was providing tools that exactly the ones I needed.
And I can tweak them and do so much more and so much faster.
Yeah.
So interesting.
And you don't have to ask for licensing or worry about that or whatever.
This portion of Talk Python To Me is sponsored by Linode.
Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
Develop, deploy, and scale your modern applications faster and easier.
Whether you're developing a personal project or managing large workloads, you deserve simple, affordable, and accessible cloud computing solutions.
As listeners of Talk Python To Me, you'll get a $100 free credit.
You can find all the details at talkpython.fm/Linode.
Linode has data centers around the world with the same simple and consistent pricing regardless of location.
Just choose the data center that's nearest to your users.
You'll also receive 24-7, 365 human support with no tiers or handoffs regardless of your plan size.
You can choose shared and dedicated compute instances,
or you can use your $100 in credit on S3 compatible object storage,
managed Kubernetes clusters, and more.
If it runs on Linux, it runs on Linode.
Visit talkpython.fm/Linode or click the link in your show notes,
then click that create free account button to get started.
All right.
Before we get off this sort of intro topic, though, really quick,
what are you up to these days?
You've got a pretty interesting job working with an intersection of a lot of these concepts.
Well, yeah.
So, you know, that sort of like do-gooder mentality has never really gone away.
And I've worked on some big enterprise systems for a whole city, let's say,
which included creating a GIS for the Super Bowl for Levi's Stadium when it was here.
I got to go to the Super Bowl.
We did every concert and event for two years before that.
So, I saw Beyonce, you know, I saw Taylor Swift or all these people, right?
Just because I built a mapping system that used Python to talk to a 911 database to locate calls that were coming from the stadium.
And also, we figured out how to put an iPhone app in the pocket of the police so that we could see where they were.
And we could keep 70,000 drunk people from beating themselves up, you know?
And so, there was that.
But then, like, after that, I felt like I really wanted to just kind of go even more into front-end development and learn more JavaScript.
So, I ended up joining a team at NIO, which is, they've, like, shut down their U.S. operations, but it's a Chinese electric car company that's working on automatic cars and self-driving cars.
And that sparked a lot.
And that team that I worked with, I did leave and go to Zillow, which I'll get to in a bit.
But that team that I worked with, I loved.
And that team, one of the main guys, Josh Butler, founded this company, Kinetic Eye, which is, I think, the biggest realization from NIO, from all the work we did, all these smart people we worked with, is that,
self-driving cars is so hard.
And so, using computer vision, using machine learning, without, like, a really directed mission is going to be an incredibly hard thing to master for the next decade or so, even if you spend $10 billion on it.
I honestly can't believe we have self-driving cars.
It's, I always thought of the AI realm being like, oh, yeah, we're going to do this Turing test, and you're going to have the app chat with somebody over text.
And then, if it seemed real enough, your AI is, like, real.
And somehow, that always felt so shallow and fake.
And then, it was somehow kind of stagnated there.
And then, all of a sudden, cars are driving themselves around at a level of complexity so far beyond that they don't even compare, right?
And somehow, we couldn't quite get one, and we got this other.
I mean, yeah.
Tesla just rolled out their beta, right, last week or something.
Yeah, exactly.
It's advancing all the time.
I still felt like it was a huge problem, and level four, level five self-driving cars, which we were working towards, was going to be a decade off.
So, this team that split off, we're focused on computer vision in small spaces, in warehouses, to see, like, how safe are people being?
How much risk are people causing with their driving habits or with their work habits?
And how can we give business owners the ability to understand how safe the practices are at their work?
How much potential risk they have for, like, a worker's comp or an injury?
And the do-gooder in me loves it because, like, injuries just ripple out throughout a community.
If somebody is hurt, then they're out of work for a while.
Then their family is hurting.
Then their community is hurting.
And we really want to, like, have this use of computer vision that identifies intelligently risk and safety.
And so, it's a cool mission and also great technology.
Yeah.
So, if I had a factory and maybe after lunch, people would come back and they weren't putting on their hard hats.
Yeah.
Or something like that.
You would say, like, ah, we're missing some hard hats?
Something like that?
Yeah.
Hard hats, vests, masks.
Social distancing was one we built right away, obviously, when COVID hit.
Oh, yeah.
Of course, yeah.
And then forklift speeding, forklift near misses is really cool because we're able to plot it on a map, you know, like, brings it back to the map.
So, all those insane, like, YouTube videos of, like, people crashing, doing stupid stuff on, like, you know, work just after hours.
Like, you would know about that kind of stuff?
Yes, exactly.
You know, we're working towards, like, a real-time notification.
I think that that's in our future.
But more than anything, it's the all-the-time risk environment that we want to let people know about.
Like, how well are you doing and how safe are your people?
Sure.
Yeah, that sounds like a great mission.
Let's talk broadly about GIS for the moment.
Just some of the areas which have been used.
I mean, we talked a little bit about this with some of the environmental things you talked about.
I mean, I guess one of the things that most starkly stands out for me, maybe two, is one, is directions.
Like, another thing that I'm just blown away by.
Yeah.
And also, probably, like, a little bit weakened by, just as a human, is GPS.
The ability to ask Google Maps or something else how to get me there.
And just, I'm thinking of the feeling I have when I, for some reason, forgot my phone or the battery dies.
I'm just like, oh, I'm done.
Yeah.
What's going to happen now?
I have no GPS.
Right?
Whereas, like, I grew up without even a cell phone.
So, it's just such a weird thing.
But absolutely GPS, right?
Well, 20 years later, it's just become part of our lives.
Like, I remember in, like, 2001, let's say, trying to drive through San Francisco and being so freaked out, driving probably the longest way I could because it was the only route I knew to get safely from one side to the other.
And just couldn't imagine, you know, how easy it is today.
I went and visited my uncle who had gone to the Naval Academy.
And he was living in Annapolis in, like, 2005.
And I had some friends in D.C.
And I said, I'd like to go visit them.
How do I get down there?
And he's like, oh, well, there's GPS in my car.
So, you can just take my car.
And it will just tell you how to get there.
And I couldn't believe it.
It was just the easiest trip I'd ever had, door-to-door, in an area I had never visited in my life.
It blew my mind.
Yeah.
It's so amazing.
I remember doing some work in Shanghai.
And I had one of the early iPhones.
And I was using Google Maps.
I had gotten into the habit of, I'd sort of pick a random orientation.
I'm going to go that way for about an hour, walking and exploring.
And when I get tired, I'm going to just hit, take me back to my hotel.
And I had gotten really far one day.
And the phone was down to, like, 10%.
And I'm like, oh, my God.
I forgot the name of my hotel.
And I can't speak Chinese.
I can't speak Mandarin.
I'm going to be in really big trouble.
So, I had to just turn it off.
I'm like, please turn back on and get me close.
You know, like, that was the most extreme concern of lacking GPS.
But, yeah, certainly those things are amazing.
Another area that I think is really probably interesting,
and maybe actually has a little more personal touch for you is agriculture, right?
Like, understanding your crops and growing things.
And just, you know, you think of sort of the idyllic farmer with just basic tools, right?
But there's a lot of IoT and a lot of smarts you can apply to those things now.
The marriage of GPS and GIS and farm tech is just all over, especially, let's say, the Midwest,
where they have, you know, one of the first self-driving applications was tractors, right?
Because it's so boring to just be in a tractor for a straight line for a long, long, long time and then turn around, right?
So, they figured out how to make the thing turn around using a satellite.
And it's pretty impressive.
I've always thought, too, that even, like, down to the small organic farms that I grew up with, you know,
where you're incredibly resource-specific, you need to know exactly what went where and keep track of it, you know, for regulations.
But also just to know what to grow next and to keep track of your nutrient levels in your soil,
that GIS and mapping would be a really great use.
I'm not sure how far it's gotten into there because a lot of them are kind of old-school hippies who don't, you know,
they still use pen and paper as much as possible.
But it's...
Maybe if you tell them it's open source and it's not corporate, they might accept it a little more.
They might love that, yeah.
So, yeah, it's become incredibly important.
And, you know, like just monitoring water levels, for instance, like, what do they call it?
NDVI, which is like how you can see how well your crops are watered or thriving
based on, like, the infrared that you can't see from the satellite imagery we can get now.
It's just incredible revelation, you know, and seeing that.
Yeah, I can imagine.
Yeah.
But then, you know, I kind of pulled away from that when I came down to the city
and got more into, like, environmental services, environmental industry.
And the two biggest projects I worked on was the high-speed rail, as I mentioned.
And then also the PG&E has power lines everywhere.
That's caused some issues because there's branches that have rubbed up on it and fires have started.
They have programs that monitor how much trimming they do around all of their lines throughout
all of Northern California, and they keep track of it.
And then they also have to kind of estimate within all that work how many, you know, endangered
species they stepped on accidentally, that kind of thing.
And because it's something that is expected work, they have to mitigate.
So, we would use GIS to calculate basically how much PG&E needed to pay.
The impact.
Yeah, the impact.
That was really cool.
The species animal equivalent of a carbon tax or carbon offset or something like that, right?
Yeah, pretty much.
Yeah.
It's just kind of how it goes.
The thing is, if they don't trim those lines, I mean, those fires are horrible this year.
And, you know, it's not like you could say, well, you just shouldn't trim them, right?
It's going to be worse, right?
It's like a necessary evil, basically.
Yeah, you have to do it.
I don't want to say I got disillusioned, but I realized in some ways that the industry
is, it's sort of just like insurance.
It's something, an expected business payment that you have to do to cover the effects of
your business, especially for those giant utilities or other large construction projects, which
is fine.
It maybe dampened my enthusiasm a bit.
But really, at that point, I was really getting excited by the technology.
It turns out I really like programming.
And I decided to move on to a company that was focused on city, like city GIS, like enterprise
GIS, being able to integrate, you know, the police with the sewers, with everything.
Because when we got there to that city, which is Santa Clara.
Basically building the smart city.
Smart city.
Yeah.
You know, they had like 11 different address databases that they were using.
Each department had their own and they were all different.
So like, imagine the police not knowing when you're at where your address is.
Well, it's more common than you would think, unfortunately.
Right.
And smart cities really appealed to me.
So I spent a couple of years doing that.
And that was amazing work.
But I just, again, really liked the programming so much.
I started moving away probably from pure GIS into a lot of like front end stuff.
But that kind of gave me an opportunity to get to know web mapping and JavaScript and all
the amazing JavaScript tools that have come out over the last 10 years to enable mapping
on the web.
Yeah.
So you worked at Zillow, for example, which is pretty awesome.
Yeah.
Zillow is definitely one of those cutting edge companies.
I remember being blown away when Zillow, when I first experienced Zillow, I'm like, I could
see what my neighbors paid for their house.
Yeah.
And the value, predicted value of it now.
And just like all that sort of neighborhood-y stuff.
Really interesting.
Yeah.
Well, when Zillow came out in like 2005, let's say, Esri really dominated the GIS space.
But you started to see these little cracks appear where like mashups, as they called them in the
late aughts.
That's right.
That was the web 2.0.
Yeah.
Mashups.
That was all the hype.
And in reality, you know, Zillow is just still a mashup.
It's a map with a data overlay of parcel information and some machine learning predictive algorithms,
I'm assuming, that go into the values, the Zestimates that you see.
Yeah, those estimates.
That's right.
So, it was really cool.
And what we were focusing on, or at least what I was brought in to focus on as the geospatial
lead there, was mapping every single neighborhood in America and Canada to understand like how
people defined the space around them.
Because again, for me, in some ways, the geography was more important than the code itself, per se.
It was.
Yeah.
And it got really cool, but that project was canceled to focus on other big projects.
So, I got into data pipelines and I did actually a lot of Spark work, some PySpark, but also
using Scala.
I did a little bit more Scala.
So, I cheated on Python there.
That's for a different podcast.
But yeah, like it was amazing work.
And it is still though, in some ways, like web 2.0.
And I kind of wanted to really be a part of the future.
I really be a part of whatever this wave is.
Is this 2.3.0, 4.0, 10.0?
I don't know anymore.
More.
4.0.
But I think that that's having worked at NEO right before that and seeing what was going
on there with the self-driving and the computer vision, which is fascinating stuff.
And just my experience with computer vision actually comes from GIS because classification
of data, of satellite data is a big part of GIS.
There's this division between like vector and raster data and the raster data coming out of
satellites.
You got to look at the pictures out of the satellites and make some sense of it.
Is that a river?
Is that a lake?
Is that a car?
It's incredible.
Just to be able to make these colors, these cells next to each other and make sense of
it.
It's incredible.
It really is.
And it still blows my mind in some ways.
So it was a natural move to go into computer vision.
And what I really realized recently is that it's not that different.
We have this video data that we're overlaying all kinds of information about what you're seeing
and you're interacting with it.
It's a different kind of map is what it is.
Yeah.
You know, I want to just dive in that for a second because I think it's so interesting
how much these skills that we develop and these things you feel are so specific to some
particular area, right?
Like GPS or something like that.
My experience from going around and doing, I used to do in-person training classes.
I remember I was one week working at Edwards Air Force Base.
Then I was working at like a hedge fund in New York the next week.
And I'm just like, these cannot be more different.
These groups.
And what I realized was I was teaching them basically the same thing.
And they both needed it exactly.
They both needed a lot, right?
And it's like, there's this sort of core of what you need to be super good at all these
ideas.
And I suspect in the GIS realm, it's kind of similar, like the computer vision, the ML,
the database, you know, geospatial queries and all those kinds of things.
Like everyone just needs that.
And then it's like that little 20% difference that goes on top.
It seems like it's the whole difference, but it's just a little bit, right?
Totally.
Yeah.
I guess we both chose wisely in that Python became our focus because it incorporates all
of those things and very nicely, by the way, I think.
And I really do think that, yeah, it's not that different.
And it is so cool to be able to just get this basic of programming, the basics of programming
and whatever you're passionate about.
And you can just take that across fields and feel really successful and useful.
Yeah.
It's super cool.
I totally have seen it happen over and over.
And I just want to highlight it because I know there's a lot of people out there listening
or knowing that would be really useful, right?
Like they probably feel like they're struggling to just make it in one area, but really that's
actually, that's the whole, that's everything.
Almost all of it, right?
It's cool.
Somebody said one time that what's he, like, it's amazing being a developer, but it's even
cooler in some ways being like, let's say a chemistry person who knows how to program,
you know, or for me, like environmental or water policy, knows how to program.
All of a sudden you're so valuable in that office.
They can't believe they live without you.
And it's not that different from other types of programming, really.
It's just data that you're manipulating.
A lot of ETL, right?
That's, that's kind of a lot of what we do.
And that's awesome.
It's so fun.
I agree.
All right.
So let's actually next spend a little time talking about some of the libraries and whatnot
that might be worth thinking about that are out there, the types of problems we can solve
with them.
So you spoke about Shapely already.
Maybe give us a quick rundown on Shapely again.
Yeah.
There's a team, I suppose, but headed by this one programmer.
I forget his name right now.
I think it's Sean.
But anyway, Shapely and Rosterio are pure Python tools for manipulating geospatial data.
Shapely is more about once you've read in the data into your code somehow, then you can perform
distance analysis or you can say, you know, is this car in this neighborhood?
How far has this car traveled?
How close was this car to this particular house?
All those questions that you might need to ask, or you might, you know, calculate demographics
across space.
Anything that you need to do with polygons, points, and lines, which is the majority of
vector data, you're able to do with Shapely.
And it's very useful in that sense.
It has a really nice interop between JSON as well.
Yes.
Super nice.
Right?
Yeah.
You can store your data in JSON like it just naturally reads and writes that.
Yeah, exactly.
There's a format called well-known text as well that it reads.
So it's very smart in that sense.
And Rosterio or RosterIO, I always get that confused, is the Roster, Raster, Roster version
of that.
I always say Roster, maybe it's Rester.
But the other one I really like that you have here is GeoAlchemy 2, which is an add-on
to SQLAlchemy, which is amazing just in itself.
Like SQLAlchemy is so cool to be able to write code for any particular or general database and
then be able to have the code work is incredible.
I really like ORMs.
I love ORMs too.
And I think that they just make data so much more accessible and remove some of the error,
potential error that you might have in working with it.
Right?
Like if I'm going to insert something, I don't forget to add this other part of it.
Right?
This piece of data.
Or you might, you know, when you load it up, you might forget to convert some value from
a string to an end or who knows.
But right?
Like you build these classes and it just, you do a few simple things and you've got a really
legit app working with a database.
Yeah.
And so that's SQLAlchemy, obviously, right?
And Django has its own version, but if you're not doing Django, basically you're probably
using SQLAlchemy, which has been going strong.
So GeoAlchemy, what's the story of that?
It is specific to PostgreSQL with the PostGIS spatial engine add-on, but it allows you to,
as you're saying, just write a database model that includes geospatial columns.
So the columns that store these points, lines, and polygons that we're describing.
And you're able to do with that module, all of these different buffers or intersections
or any other kind of geospatial analysis that you need to do directly with the data that
you're storing in your database.
Nice.
So if anyone's familiar with SQLAlchemy, it's exactly the same.
Like you create a declarative base, you create an engine, you do the create tables, like all
that stuff that you do, you create a session and you add stuff to it.
So like all those are the same, but you can have interesting stuff.
Like you could define a class, which is a lake, for example.
And it's got a primary key, which is an ID.
It's got a name, which is a string, but then it could have a geometry, which is a polygon,
which is one of these things coming out of GeoAlchemy, right?
Yeah.
Well, GIS, yeah.
In general.
Yeah.
Exactly.
So you just create, like, it's just a different column type out of that library.
Yeah.
And yeah, you're out to the races.
There's always a weird idea within GIS that, like, is spatial special data?
Are we specialists or are we tech people?
Like, there's always kind of a weird nebulous feeling there.
And what it does in some ways is it makes spatial data not special.
It makes it really easy to deal with.
It's logical and stored exactly like any other data in a column.
Associated features are right there in that same row.
And you can do relationships with it, like just like an ID-based relationships.
But you can also do spatial relationships.
You can say, given this neighborhood, how many homes above this age or this price, let's say,
exist in that neighborhood?
You know, that kind of query.
Yeah.
And you can just treat it like just any other data, but there's just this couple of special
tweaks that allow it to be really flexible.
And it's just more database queries, just like the session.query of, like, lake filter.
And then it's like, excuse me, the geometry contains this point or it intersects this line.
And presumably those are done with, I guess, some form of an index.
So that's fast.
Yes.
I don't really know, right?
There's spatial indexing that improves it quite a bit.
In fact, with the right engine underneath your database, these queries go fast for millions
of points.
Postgres is pretty, pretty amazing for being a free digger.
It's pretty awesome.
Yeah.
It is super cool.
You know, we were talking a little bit about it earlier.
Like Tinder, you know, all these modern apps are geospatial because they've just integrated,
you know, where you are, where are the object that you're interested in, or like Uber.
Like, you know, nobody understood what I was saying when I said GIS.
But when I finally was like, oh, it's like Uber, you know, you see where you are and you see
the car coming to you, which is...
And you see the roads where it can go and maybe even optimize a path if it's like a
shared Uber, whatever that is called.
All of those are geospatial.
Sure, they don't share anymore, but they used to.
I know, right?
Yeah.
They used to work together when they had to.
Yeah.
So it's built into our modern lives in ways like you were talking about mapping, you know,
but it's mapping plus information overlay and sorting through that information to find the
things that are interesting to you across a varied and unique space that you may not be
familiar with.
A new city.
Yeah.
Well, when you were first talking about studying your master's degree in geography, just thinking
back of when I was in middle school or something, I was like, well, what you're going to have
to do is name all the states in the US.
You have to name all the countries in Europe.
Like, okay, well, not super interesting, but I guess I'll like, I'll commit that to memory
and we'll just, we're going to do this, right?
And then probably forget most of them.
And, you know, that's kind of was my like young mind's impression of that.
Yeah.
But, you know, if you think of like space overlaid with flowing data and all the questions
and answers that you have, all of a sudden it becomes this really interesting programming
problem and a really important for people's lives.
Well, let me have a quick diversion here.
So back in the thirties, especially there was a lot of geographers hired to like make flood
maps or other kinds of maps.
They were trying to figure out like, where are disparities across space and how can we help
people?
And it was a top level science.
Geography had departments all across like Harvard, Yale, all of those schools.
But then to be honest, there was like a supposed like homosexual scandal at one of these schools
where like, you know, a geography professor was living with one of his grad students and
president who had skepticism around the science itself kind of decided just to cut it out.
And because like he gave a different reason for it, but that was the rumor behind it all.
Oh my gosh.
Yeah.
So it was Harvard or Yale.
They cut it out.
And then all the other top IVs followed.
But in most other countries, geography is a top level study because you're really understanding
like, why are these people suffering from pollution more than these people next to them?
What are the prevailing winds?
What are the reasons that they live there?
What are the historical, you know, why were black communities affected by freeways in the
seventies more than other communities?
You know, it was partially their political power, partially where they were living because the
elevation was flatter and it was more prone to floods.
There's just all these geographic questions that are kind of amazing to study and you can
get hyper-specific with it, but didn't appeal apparently to these top level schools until
around 2005 when Harvard started its spatial library.
And that was like a GIS focused library.
And they brought back geography or at least some component of it that was tangible to them.
Oh, wow.
Yeah.
I had no idea about that history.
Nobody does.
It is sort of a unique component to this like science.
That's everywhere and nowhere.
No pun intended, really.
Yeah, absolutely.
So we talked about geo-alchemy.
There's a geo-alchemy there.
It's called geo-alchemy 2.
What happened to 1?
Or no suffix.
Do you know?
Go straight to 2.
You know, whoever started 1 abandoned it and somebody else took it over.
Yeah.
But they didn't want to edge it out or say, all right, we'll call it 2.
Yeah.
If we're in Django, we have geo-django.
That sounds better.
Geo-django.
Sounds fun.
But maybe it's got to live within the Django models and stuff like that.
Yeah.
Obviously, if you're using Django, you probably would consider that.
It's actually right built in.
You just have to import one more thing in your admin.py.
I believe that's what it's called.
Or I haven't used geo-django in a few years.
But it's like, you know, right from the get-go, when Adrian and his buddy were designing Django,
they were doing the EveryBlock project that they ended up selling to CBS, which was kind
of like a citizen app in 2007 where they were saying, like, here's what's happening on every
block in America.
And so, geography was built in early into Django.
Oh, interesting.
I had no idea about that history.
Yeah.
I mean, Django comes out of newsrooms, right?
Yeah.
It came from the lore and internal world or something like that.
So, it makes total sense that it would have that, some of those ideas in there.
Yeah.
As soon as he left, Adrian, I forget his last name right now.
Anyway, he started EveryBlock and I think he did well selling that.
It was like a huge part, as you said, and it's very much related to reporting.
So, I was like, yeah.
I'm more into Flask these days, which it's just kind of simple and you can just add what
you need when you need it.
No disrespect to Django.
Django's fantastic.
Yeah.
So, if you're in Flask, GeoAlchemy too, obviously, right?
Yep.
But if you're in Django, probably you just use the features that are
built straight into it, right?
Tons of tutorials about it all around.
Yeah.
It was well supported.
Yeah.
So, you have some that are on ArcGIS, which is the Esri commercial package, which they actually
do a ton with Python as well over Esri, which, so if you're doing Python, you might, it might
still be a great place to be, but it's also, you know, something you pay for.
So, you might alternatively consider some of the piecing together things from some of the
open source tools, right?
But yeah.
So, tell us about your books.
Sure.
Yeah.
I got the opportunity, having volunteered to review some books in like 2012, an early
open source Python GIS book.
It was great.
And I was on PAC Publishers list and they kept emailing me like, can you write a book about
network security and Python?
And I was just thinking, no, I can't.
I don't know anything about that at all.
How about cutting edge cryptography?
Have you done that?
Yeah.
Exactly.
I also know.
Sounds like you've got the same emails, huh?
Yep.
So, I finally wrote back to them.
I was like, look, I am a GIS professional and I can write about that.
If you have any interest, let me know.
Otherwise, stop emailing me.
And they said, yeah, actually we do.
So, they recruited me to write a book on ArcPy, which was at that point about five years old,
but it was just getting more and more prominence.
And I was obviously an early proponent.
And I wrote that first book, ArcPy and ArcGIS, Geospatial Analysis with Python, which we did
a second version of me and my coworker, Dara.
And that one focused more on the newer ArcGIS Pro, which uses the Python library for that as
Python 3.
The problem with ArcPy is it's Python 2 based.
So, it'll be supported for a while in terms of Esri, but the greater Python world is rapidly
leaving it behind.
Yeah.
There are some interesting industries that kind of get stuck.
They so embrace Python, but they embrace it in a way where they package it into their tooling.
And I'm thinking of the movie and entertainment workflow industry.
There's all these tools like Maya and whatnot that have Python built in.
And a lot of them embedded the Python 2 runtime.
And they're just, until they as a group decide to change, they're like, that's how it is,
you know?
Yeah, exactly.
You know, Esri keeps trying to retire its ArcMap product in favor of this new ArcGIS Pro.
But it's not going to happen because they have a huge sort of lazy, let's say, no offense,
workforce that doesn't want to learn a whole new software.
And I totally get it.
Yeah, maybe they have stuff that works and they don't consider building those things
or maintaining their job.
They just need that to work for their job, right?
And that's good for them, but it's a tough place to be.
They wrote this software called Avenue, which was their original programming language or one
of them in the early aughts.
And people are still using some of those scripts, I'm sure, in places.
So, you know, things stick if they work, just like you said.
And it makes sense.
Yeah, so you took another take on this.
Yeah, and it was fun.
I actually recruited some help because writing books is a lot on Twitter and found a couple
guys that I follow on Twitter.
And we wrote this book, Mastering Geospatial Analysis with Python 3, which is like a 16-chapter
review of available modules.
Does a pretty good job of going from like very specific geospatial stuff all the way up to big
data.
And there's a couple chapters in there on interactive web mapping that I wrote around
Flask and GeoAlchemy as well as GeoDjango.
I thought it was great.
We even touched on, do you know what MapD, they became OmniSci.
It's sort of a...
Oh, I don't know.
It's like a GPU database tool that does some pretty amazing visualizations.
And they have a Python module, PyMapD.
They may have changed the name.
Yes, things like that.
Like all these incredibly cool modules that just kind of blew me away.
We just touched on it really because there's so much to touch on.
But I think it's a great book.
I really liked writing it and it's so wide.
Well, it sounds like it really does a good coverage of all these things if you're into
Python plus geospatial.
Yeah.
Well, yeah.
It's not like it's selling like hotcakes or anything.
You know, these...
Well, not before your appearance on the podcast.
Yeah, there you go.
Yeah.
I'll be looking for those checks rolling in, right?
That's right.
Yeah.
I would say it's only 30% like the App Store.
Don't worry, I'll be fine.
No, just kidding.
But speaking of podcasts, you spent close to a year doing a podcast on GIS topics, right?
I did.
And that was a joy.
I mean, it's fun being back here and remembering how much fun this is.
My co-host, Todd Barr, who is the spatial punk.
He's sort of Esri's aside and the thorn of Esri is sort of his like thing.
And, you know, he's just criticizing like the lack of support for big data and just really
innovative or any kind of innovation the way he sees it.
I think like there's some great tools coming out of Esri like ArcPy and ArcServer is very
cool.
But he felt like within the realm, they had too much dominance and not enough like push
towards really cool, new and fast pipeline supports, especially for big data.
So we had a lot of discussions with all kinds of different users, though, around like different
focuses, cartography to big data to archaeology.
We had a journalist up in my hometown who does like a, it's a Django based website that gets
like 3 million hits a month.
And they use a lot of GeoDjango to like locate where all the different, say, arrests or accidents
happen.
They just pull in records from the courthouse and automatically add location to it.
It's one of those things like you were saying about just adding in just a little bit of Geo
that makes your field, whatever it is, way better.
Yeah.
I recently did an episode on Python and AI ML in journalism.
And there was a lot of geospatial stuff there as well about like automatically understanding,
you know, like earthquakes in real time or crime in real time and those types of things as
well.
So yeah, I think it spans a lot.
Have you heard of a hood line down here?
Hood line?
No.
They've gone national.
In fact, I think they were purchased by Nextdoor, but it is a journal.
It's like a local neighborhood journalism site focused on all kinds of different cities,
but it started here actually in the neighborhood.
I live in San Francisco in the lower Haight.
And it was all about trying to automate a lot of the like exposition within a story.
If like a restaurant opened or something, they could tell you about all the other restaurants
that opened within a certain radius, that kind of thing.
So machine learning and ghostwriting a lot of their stories was a big focus.
I thought it was amazing.
Oh, yeah.
How interesting.
That makes perfect sense for Nextdoor, of course.
They're trying to like hyper local stuff.
Maybe just give us a quick couple of your favorite episodes for your podcast.
People, I'll link to the show and people can check it out if they're interested.
The cartography one with Sarah Bell was really fun because we talked to her about just kind
of, you know, cartography and her GIS career, but also like what it's like being a woman in
the field and how she's loved it and hated it at times.
That one really resonated.
I thought the journalism one was fascinating because, you know, we're talking about all kinds
of different crazy stories that they've covered.
For instance, they did a, you know, where I'm from, Humboldt County, there's a lot of
marijuana up there.
And so they did like a comparison with satellite imagery saying like, do you think this satellite
has marijuana grown in it?
And it pissed off all the locals, but it made for an amazing like application through their
website.
It's kind of a crazy mix of GIS and crime and reporting, which is just such a fascinating
way to approach the world because that's really how things work.
You know, things are located somewhere.
Yeah.
And a lot of those things are affected by the location that you're in, right?
Quality of schools, the attitude or predispositions the police might have and perceiving the people
in that neighborhood may vary a lot, right?
Things like that.
Oh, yeah.
You know, you can tell these stories with data, right?
Yeah.
Well, I was, so the CEO of Hoodline, when she brought me on as a consultant, I was encouraging
her like, you have to know every gang territory in LA, you know, like that's the kind of thing
that would really make for an amazing story, especially for automating it.
So we never went that far with it, but I think there's still room to do that.
Yeah.
I guess there probably would, right?
Yeah.
So the Mappiest Hour was really fun.
And Todd was a great co-host.
We're still talking about doing some more maybe next year, but it was a very big year for
us both.
Yeah.
So you had, you had season one and then maybe you could do season two.
There you go.
Yeah.
Well, with this kind of encouragement, I'm loving this.
So yeah, maybe I'll just ride this wave.
Call them out.
It's always fun.
Yeah.
You're just like sort of a bit of a sidebar with fellow podcaster.
Like it's really interesting that the people that you get to meet, right?
If there's so many folks that I've spoken to that generally, at least before I got into
the podcast, you know, five years ago would have not really bothered to give me the time
of day, or at least they wouldn't have been excited about it.
Right.
And now I, almost everyone I reach out to is excited to be part of the show, to share
their story, to talk, and you just get to meet so many interesting people.
It's just such an honor to sort of be part of that.
Right.
It's cool.
Oh my God.
It really is.
I'm loving this.
And you must have just so much fun.
You're doing this full-time now or?
Full-time.
Yeah.
Two shows a week.
Yeah.
It's great.
Oh, that's great.
It's just such a cool dive into who we as developers are, which is much more, much less
monolithic than it sounds like initially.
And there's just so many different ways and things you can do with code.
Yeah.
And you touched so much on it when you talked about that person who, not necessarily a CS grad,
but some other expertise, but now has the magic programming power that
most people don't.
And there's just so many interesting stories and use cases and libraries and applications
coming out of that side of the world that it's bottomless.
It's cool.
Just got to grasp what a for loop is and you're well on your way.
Exactly.
Pip install and you're going to be good.
All right.
Let's see.
One more thing that we threw out to talk about was WebGIS for Flask or Django APIs.
Tell us maybe about that real quick.
Well, you can just do some amazing APIs with Flask or Django in general, but with Geo, especially
with if you're building like a phone, an iPhone app or an Android app, you know, you can just
send your location and have all kinds of context sent back to the application based on these
APIs.
So they're quick to put up.
They're easy to maintain and you can integrate spatial right into it.
It really isn't that much work.
There's a little bit deeper understanding of like the type of spatial function you may
need for a specific moment.
But none of that is going to take a master's degree.
In fact, I think just like reading some online tutorials or some stack.
There's a Geo stack overflow even, I think.
Oh, cool.
Yeah.
The GIS dot stack overflow.
Something like that is very, very useful.
A stack exchange.
Yeah.
Probably.
There you go.
That's it.
Yeah.
Or you can buy my books.
Yeah.
Now, the amount of data that you have to exchange is actually pretty small for these applications.
Like where am I or what path have I taken?
Yeah.
And so on.
But it's easy to build APIs random.
I would suspect like on the back end, have it something like Geo SQL, Geo Alchemy 2.
Just indexes.
Make sure you have indexes.
The coolest thing I ended up doing at Zillow was building what we called the Surveyor.
It was just a working title, but it was a just literally a web map built in Flask, PostGIS,
to be able to actually see a lot of the data that we were building and creating and comparing.
Because internally, we didn't have like a mapping tool that could really speak to all of the geospatial data that we had.
It was such a surprise to me.
And I ended up winning the Hack Week there earlier this year before I left.
And that was just like so fun because I presented it at the end of Hack Week.
And they instantly were like, yes, why don't we have this already?
That's awesome.
That's super cool.
Congratulations.
One more thing on the library side, I guess, is probably worth throwing out.
So we've talked a lot about server side things.
And you talked about your cool experiences with JavaScript in the front end.
If I'm going to do mapping data, especially interactive maps,
there's got to be some fancy library that goes on the front end that makes this happen.
So what would you recommend to check out?
Sure.
Yeah, there's less fancier ones, I would say, that Leaflet is considered, which is a JavaScript library.
It's considered a medium level knowledge that you could use.
And then MapGL, Mapbox GL, I'm sorry, is a little bit higher level, but it has really fine controls over what you can do.
And you can have all kinds of events.
There are some pure Python front end tools like Dash and a few others that do have mapping integrated as well as graphs.
And that can be really useful.
You don't have to handle much of the HTML if you don't want to.
But I find it, if you're going to get into interactive web mapping, really useful to know both Python and JavaScript to make them work together.
Yeah.
A lot of the interactive stuff happens on, it has to happen on the client side, right?
Yeah.
So that means some kind of JavaScript.
Get used to curly braces, right?
Yeah, exactly.
Don't forget the semicolons.
Actually, in JavaScript, you can forget them, which is kind of good, I guess.
It took me a long time to get into JavaScript because I was so used to the clean nature of Python.
Like, and no joke, that attracted me to Python.
It was so important to be able to read the code.
Yeah, and I feel like JavaScript used to be closer to that world.
It used to be pretty simple.
Now it's like, you know, all sorts of dependencies require this.
And then like, you know, you pack up these things and it's just like, oh my gosh.
Or, you know, you pre-compile or transpile your TypeScript over to this and then you pack it up and you minify.
It's like, whoa, whoa, whoa, whoa.
What happened to just including something in the page?
I mean, when I do demos or proof of concept, it's always pretty vanilla with like one mapping library or something.
There's some other cool ones too that Uber is putting out a ton of really cool stuff like deck.gl.
And there's another one I forget.
But if you want to get into super fancy data visualization, I recommend looking into Uber's set of JavaScript tools.
It's pretty amazing stuff.
But yeah, I prefer a much more vanilla implementation of myself just for my brain to manage it and to understand it.
Yeah, super cool.
All right, let me close out our conversation with one sort of more general question here.
So people out there listening, a lot of them have Python skills, obviously, or building up their Python skills.
How much do you need to know to be useful and powerful?
Like, do you need to go get a degree?
How much work is it to get into this?
If you want to really understand the theories behind geography, yeah, I think grad school can be really useful or just an undergrad degree because it really helps you understand like just why it's cold in the Arctic and warm at the equator.
Like just at that basic level.
It is amazing.
And the relationship between the two and the relationship between that and human culture.
So if you want to really understand humans, yes, go into geography.
But if you want to make a geospatial data pipeline, I think what you really have to know is just like what is the data you're getting in and what is the data you want to get out and what are your resources in between.
You don't have to know much more than that.
There's all kinds of tutorials.
There's books.
There's a weekend of exploration ahead of you.
It's not that hard, but it is really powerful.
Well, it does sound like a really fun area to get into.
And a lot of times these visual aspects are pretty cool for people who are not sure that they're necessarily programmers.
But then if you build something that you can see and touch and share, like all of a sudden it makes a big difference, I find.
Completely agree.
It's one of the coolest things you do.
And I still get that thrill I got, you know, from showing my grandmother the little lat long that I was able to pull from a shape file.
Super cool.
All right.
Now, before I let you out of here, you got to answer the two questions I always put at the end of the show.
If you're going to write some Python code, what editor do you use?
Lately, it is PyCharm.
I really like it.
Before that, it was sublime because it's just simple and you don't have to think too much about it.
But PyCharm is fantastic.
Yeah.
It's my favorite as well.
I love it.
And notable PyPI package.
I mean, we definitely threw a bunch out there.
I think PyShape is the lowest level one because unfortunately still this really ancient data format is the major data format in
GIS.
So PySHP, that tool will allow you to read and write it just in pure Python.
Awesome.
Cool.
All right.
So final call to action, people are interested in GIS.
What do you say to them?
And Python.
It's an amazing field.
How do I put those together?
Yeah.
This is the future.
Or maybe the future is here.
But either way, there's so much that can be done in this space.
We're just touching on it.
People are just hearing about it, let alone realizing that there's so much more to do with it.
So, yes, come join me.
Yeah.
It definitely feels like maybe the future is here.
It feels like part of the future.
Like I remember so many of these things, the GPS stuff, the Zillow stuff, all those different just literally blew my mind when I saw them.
And I'm reminded of the William Gibson quote.
Like the future is here.
It's just not evenly distributed.
Exactly.
Yeah.
That is so true.
The future is generally in your hands these days, but not everybody has the same phone.
That's true.
All right.
Well, Silas, thank you for being on the show.
It was great to chat with you.
It was so fun, Michael.
Thank you so much.
Yeah.
Thanks for sharing this.
See ya.
This has been another episode of Talk Python to Me.
Our guest on this episode was Silas Toms, and it's been brought to you by us over at Talk Python Training and Linode.
Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
Develop, deploy, and scale your modern applications faster and easier.
Visit talkpython.fm/Linode and click the create free account button to get started.
Want to level up your Python?
If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
Or if you're looking for something more advanced, check out our new async course that digs into all the different types of async programming you can do in Python.
And of course, if you're interested in more than one of these, be sure to check out our Everything Bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, the Google Play feed at /play,
and the direct RSS feed at /rss on talkpython.fm.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
Thank you.
you
Thank you.