python-training
python-training copied to clipboard
Update cartopy training unit
I put this together to answer a question:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=ccrs.LambertConformal())
# Rectangle in projection coordinates
rect_proj = plt.Rectangle([-500000, -500000], width=800000, height=800000,
facecolor='none', edgecolor='tab:blue')
ax.add_artist(rect_proj)
# Rectangle in lon/lat coordinates
rect_geo = plt.Rectangle([-105, 40], width=15, height=15,
facecolor='none', edgecolor='tab:red',
transform=ccrs.PlateCarree())
ax.add_artist(rect_geo)
ax.coastlines()
ax.set_extent((-120, -65, 20, 55))
It'd be nice to make use of this in our own training.