O'Reilly logo

IPython Interactive Computing and Visualization Cookbook by Cyrille Rossant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating geospatial data with Shapely and basemap

In this recipe, we will show how to load and display geographical data in the Shapefile format. Specifically, we will use data from Natural Earth (www.naturalearthdata.com) to display the countries of Africa, color coded with their population and Gross Domestic Product (GDP).

Shapefile (http://en.wikipedia.org/wiki/Shapefile) is a popular geospatial vector data format for GIS software. It can be read by Fiona, a Python wrapper to GDAL/OGR (a C++ library supporting GIS file formats). We will also use Shapely, a Python package used to handle two-dimensional geometrical shapes, and descartes, used to render Shapely shapes in matplotlib. Finally, we will use basemap to plot maps.

Getting ready

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required