Chapter 7. GeoPandas and Spatial Statistics

Maps are beautiful. The stories they tell can be so captivating that it’s easy to unintentionally disregard the geospatial statistics within them. But geospatial maps are not simply static images. There is information embedded in them, such as attributes associated with a specific feature in a GIS layer or pixel densities observed in raster images.

Python has a variety of packages for working with geospatial data. If you are familiar with Python, you likely know pandas, a data analysis tool built specifically for Python. Pandas allows us to read a wide variety of data types into a dataframe: a set of tables containing rows (which denote records) and columns (denoting attributes). GeoPandas is an extension of pandas that lets you manipulate geometric and geospatial data using what it calls a GeoDataFrame: a geospatial dataframe in which each row is a spatial feature, such as a point, line, or polygon.

This chapter will show you how to analyze your data and create maps using GeoPandas and GeoDataFrames, as well as some other important packages, such as matplotlib to visualize data and Census Data API. You will also learn how to access geospatial files and delve deeper into demographic data by creating and comparing demographic maps.

Installing GeoPandas

To install GeoPandas, you’ll use conda and conda-forge in your terminal. As in previous chapters, I’ll also show you how to create an environment for all the files you’ll need ...

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

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