How to create map projections

Import all of the usual things, as done in the earlier sections. Import Basemap from mpl, as shown here:

from mpl_toolkits.basemap import Basemap
Basemap does not come with Matplotlib by default, so we need to do a pip install of basemap, or, if you're using Anaconda, install it using the inbuilt toolkit.

The simplest map projection we get is the one where we translate latitude and longitude into x and y coordinates, and also when we create a basemap object with no projection keyword argument. Each of the following arguments represents a different parameter: llcrnrlat shows the minimum latitude, urcrnrlat shows the maximum latitude, llcrnrlon shows the minimum longitude, urcrnrlon shows the maximum longitude, ...

Get Mastering Matplotlib 2.x 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.