Book Review: Learning Geospatial Analysis with Python by Joel Lawhead

A decade ago I purchased the first edition of Learning Geospatial Analysis with Python by Joel Lawhead. I was fresh from graduating from the MSc in Geocomputation at Maynooth University where our lecturer, Martin Charlton, gave us a term I will always remember, “buttonology”. Buttonology, he described, was the pushing of buttons in ArcGIS (or any other GIS), without any real knowledge of what was going on under the hood, and blindly accepting the output of any geoprocessing and geospatial analysis to be correct. Martin lifted up the hood and showed us the inner workings and the algorithms (the magic) behind the geoprocessing and geospatial analysis and we learned R programming and Python along the way. It was pure luck that I came across the Learning Geospatial Analysis with Python book back then, but it added to my arsenal for advancing my career and adding real value to geospatial projects. Having just completed reading the fourth edition of this book I can truly say that the material has aged very well and modernized where required. The title of this post is a little deceiving, this is not going to be your typical book review. Technical book reviews are generally boring and a synopsis of each section/chapter of the book, sure you can read that from then contents of the book. Instead, here, I am going to list why you should consider reading and following along with the technical workflows of the Learning Geospatial Analysis with Python book by Joel Lawhead, and how they have related to scenarios in my own career.

A Brief History of GIS & Geospatial Analysis

This history is fascinating, full of “how did they do that back then?”, especially with the first ever world Atlas. Unless you have completed a full blown GIS course at University level, it is highly unlikely you have read about the history of GIS and geospatial analysis unless your own interest took you there. While the history presented in this book is selective and condensed, it certainly hits the more important key moments. Knowing the history won’t add to your GIS skills, but it will provide you with valuable insights into the evolution of geospatial technologies, the challenges overcome by pioneers in the field, and the diverse applications that have shaped its current significance.

“Napoleon’s March” (bottom half of image) by Charles Minard displays quantitative information about lives lost as shown by the thinning of the red and black areas in the graphic. The graphic was created in 1869. See more over at National Geographic.

GIS Data Types Simplified

Every GIS/geospatial book should have this embedded in it, and I think for the most part they generally do. This makes it easier for someone coming from a non-geospatial background to grasp the core concepts of vector and raster data, the two main GIS data types. It is especially essential for technical publications. One thing I loved about this book was its foundational approach. Starting with the basics and building up piece by piece. We all know, or should know, that we can have a point, multiple connected points can create a polyline, and an enclosed polyline can make a polygon (I’ve over simplified but you get the point [pun intended]). Sounds simple, but this is crucial for creating and editing geometries in GIS, especially when programmatically performing edits. We all want to jump straight into the sexy and cool geospatial workflows, but after reading this book you will take away a new found appreciation for the fundamentals of GIS and how they fine tune the brain for not only advanced geospatial analysis but also to aid with troubleshooting. The basics are the important foundation block for geospatial analysis.

Digging into Geospatial Filetypes

This is something that often separates geospatial professionals apart. I once worked at a company and we were going to be receiving a GeoJSON file on a weekly basis and we needed to ingest that data into our system, which was ArcGIS Enterprise, so the data would ultimately be converted to a feature class in and enterprise geodatabase. Should be simple enough, sure there’s an ArcGIS geoprocessing tool to handle that, and if that fails we have GeoPandas and other avenues to try. A colleague was attempting to do the conversion, but could not get it to work, this was a showstopper. This is where a lot of people stop, the tools are not working, what do we do? Give it here to me and we’ll dive deeper into the inner workings of the filetype. The first step was to convert a feature class from our enterprise geodatabase to a GeoJSON file, and the next step was to open the two GeoJSON files side by side in text editors. The incoming GeoJSON file was was not formatted correctly, it wasn’t blatantly obvious that this was the issue until you actually saw what correct looks like. We sent back instructions for the incoming data and we had no problem converting going forward. This is one example of many. One of the best things you can do is learn the makeup of different filetypes (Shapefile or XML for examples) so that you are a troubleshooting extraordinaire and this book sets you on the right path for thinking this way and has great examples of dissecting filetypes using Python.

The Geospatial Technology and Python Library Landscape

It’s vast and ever growing! and you have to remember that ArcGIS does not equal GIS! It is simply a GIS software, there are plenty more out there. I remember reading the first edition of this book 10 years ago and learning the main geospatial libraries that make up most of the proprietary GIS software offerings. The author, Joel Lawhead, enlightens us with how GDAL, PROJ, GEOS, and JTS are the core components for a lot of our GIS software and that we have access to core libraries in some way or another via Python, which of course is what the book is all about. We are then introduced to a selected list of Python libraries that utilize or compliment those core components and we will witness the use of many of these throughout the book; GDAL and OGR, PyShp, Shapely, Fiona, NumPy, PIL, PNGCanvas, GeoPandas, PyFPDF, PyMySQL, Rasterio, OSMnx, and Folium. These introductions will have you craving more and I bet you will look at multiple of these in more depth afterwards. Many years ago I went into a deep dive of Shapely, you’ll soon realise that you can achieve simple (and some more complex) geospatial workflows without the need for proprietary software, this adds value to what you can offer clients, especially if they have basic GIS requirements and want to automate.

Real World Application of Geospatial Analysis

From easier to more advanced implementations, this book gradually builds up in complexity and is littered with fantastic and insightful workflows that are applicable in the real world. Do not be scared of the code snippets if you are new to programming and Python, it can be daunting, and remains daunting, trying to read someone else’s code. At an early stage of your learning path it is more than efficient to just to know what Python can achieve in regards to geospatial analysis. The workflows presented in this book will get your imagination firing on all cylinders. When I started out coding with Python StackOverflow was my best friend, I copied and pasted code. I knew what the inputs where and what the output should be, but more often or not I did not understand the code, but it worked and I used it. A couple of years later I revisited many scripts and it was like I could read in another language, the code started to make sense and I could even refactor to make the code more efficient. Joel walks you through each algorithm as if he is holding your hand, and this is the important part, you are being walked through the algorithm, the steps required to achieve the geospatial analysis or expected output from the analysis, this will give you an understanding of the code but it won’t describe what each line of code is doing. Only with consistent utilization of Python programming (for geospatial analysis) will you build up coding skills over time and be more comfortable with reading someone else’s code. One great takeaway from this book is that many of the code snippets can be reused or repurposed in your daily geospatial tasks, see the next section for more information.

Technical aspects in the book that will pique your geospatial interest…

Here is a small, but not exhaustive list, of technical entries from Learning Geospatial Analysis with Python that really should grab your interest, especially if you are a student or early in your Python programming endeavours with geospatial analysis.

  • Measuring distance algorithms
  • Calculating line direction (I have used this algorithm many times)
  • Geocoding (and reverse Geocoding)
  • A deep dive into using Python with Remote Sensing imagery and elevation data
  • Working with real-time data
  • Geolocating photographs (used many times in the past)
  • Creating a simple flood inundation model for hydrology
  • Generating PDF reports
  • Using ChatGPT prompts for script generation
  • and many more!

This book will not…

Teach you the basics of Python programming, it assumes you have this basic knowledge already.

Where you can get your hands on the book?

If you are interested in getting your hands on a copy of the book, which I highly recommend, you can do so at this link here or click on the image below.

Disclaimer

While this book was gifted to me I am under no obligation to review it in a positive manner, it just happens that this is an excellent technical text book. I saw a post on LinkedIn from the author, Joel Lawhead, searching for people to review the book and I enquired because of the impact purchasing and learning from the first edition had on my train of thought as I progressed through my own geospatial career. With this upgraded edition, it remains one of my favourite (open source) Geospatial Python books and it was a pleasure to have the opportunity to review it. While no book is all encompassing, this one is a solid entry point for Learning Geospatial Analysis with Python.

Subscribe to our blog…

Leave a Comment

Your email address will not be published. Required fields are marked *