Examples of how to plot a circle on a cartopy map with python:
Plot a red circle using PlateCarree projection
To plot a circle on a cartopy map, a solution is to use matplotlib patches :
from matplotlib.pyplot import figureimport numpy as npimport matplotlib.pyplot as pltimport cartopy.crs as ccrsimport matplotlib.patches as mpatchesfig = figure(num=None, figsize=(12, 10), dpi=100, edgecolor='k')map_proj = ccrs.PlateCarree()ax = plt.axes(projection=map_proj)ax.set_global()ax.gridlines()ax.coastlines(linewidth=0.5, color='k', resolution='110m')poly = mpatches.Circle((2.52, 48.8), 12.5, color='r', transform=ccrs.PlateCarree())ax.add_patch(poly)plt.title('How to plot a circle on a map with cartopy ?')plt.savefig("plot_circle_cartopy_PlateCarree.png", bbox_inches='tight', facecolor='white')

Plot a red circle using Robinson projection
With another cartopy projection
from matplotlib.pyplot import figureimport numpy as npimport matplotlib.pyplot as pltimport cartopy.crs as ccrsimport matplotlib.patches as mpatchesfig = figure(num=None, figsize=(12, 10), dpi=100, edgecolor='k')map_proj = ccrs.Robinson()ax = plt.axes(projection=map_proj)ax.set_global()ax.gridlines()ax.coastlines(linewidth=0.5, color='k', resolution='110m')poly = mpatches.Circle((2.52, 48.8), 12.5, color='r', transform=ccrs.PlateCarree())ax.add_patch(poly)plt.title('How to plot a circle on a map with cartopy ?')plt.savefig("plot_circle_cartopy_Robinson.png", bbox_inches='tight', facecolor='white')

Related posts
| Links | Site |
|---|---|
| How to plot a circle in python using matplotlib ? | moonbooks.org |
| How to plot a heatmap over polar regions using cartopy, matplotlib and python ? | moonbooks.org |
| How to plot a heatmap (gridded data) on a global map with cartopy in python ? | moonbooks.org |
