Exemples de comment tracer un cercle sur une carte globale avec cartopy et python:
Tracer un cercle rouge à l'aide de la projection PlateCarree
Pour tracer un cercle sur une carte cartopy, une solution consiste à utiliser 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')

Tracer un cercle rouge en utilisant la projection de Robinson
Avec une autre 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')

Voir aussi
| Liens | Site |
|---|---|
| Comment tracer un cercle avec matplotlib de python ? | moonbooks.org |
| Comment tracer une heatmap pour les régions polaires avec cartopy, matplotlib et python ? | moonbooks.org |
| Comment tracer une heatmap sur une carte globale avec cartopy en python ? | moonbooks.org |
