Creating a map with cartopy
There is a multitude of libraries based on Matplotlib dedicated to the creation of specialized graphs. In this recipe, we will discuss cartopy, which is a Python package for creating maps and handling the display of geographical information.
Getting ready
The first step is to install cartopy on your system. Since cartopy assumes a large number of dependencies, this recipe assumes that you have the Anaconda distribution installed. This being the case, simply run the following statement from the command line to install cartopy:
conda install -c conda-forge cartopy
After the installation finishes, start Jupyter and run the following three commands in an execution cell:
%matplotlib inline import numpy as np import matplotlib.pyplot as plt
How to do it…
Enter the following in a Jupyter code cell and run it:
import cartopy.crs as ccrs fig = plt.figure(figsize=(10,10)) ax = fig.add_subplot(1, 1, 1, projection=ccrs.Mollweide()) ax.coastlines() ax.stock_img() rj_lat, rj_lon...