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
You need the following packages:
- GDAL/OGR available at www.gdal.org/ogr/
- Fiona available at http://toblerity.org/fiona/README.html
- Shapely available at http://toblerity.org/shapely/project.html
- descartes available at https://pypi.python.org/pypi/descartes...