如何在 Cartopy 中绘制国家边界
使用
how-to-draw-country-borders-in-cartopy.py
import cartopy.crs as ccrs
import cartopy.feature as cf
from matplotlib import pyplot as plt
ax = plt.axes(projection = ccrs.Mercator())
# 这将添加边界
ax.add_feature(cf.BORDERS)以下代码展示使用 cartopy 绘制国家边界(和海岸线)的最小示例:
cartopy_borders_complete.py
import cartopy.crs as ccrs
import cartopy.feature as cf
ax = plt.axes(projection = ccrs.Mercator())
ax.add_feature(cf.COASTLINE)
ax.add_feature(cf.BORDERS)
# 使图更大
plt.gcf().set_size_inches(20, 10)
# 将图保存为 SVG
plt.savefig("Cartopy-Borders.svg")If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow