gpt4 book ai didi

python - Cartopy 中正交投影的 Shapefile 绘图问题

转载 作者:行者123 更新时间:2023-12-01 03:29:42 25 4
gpt4 key购买 nike

相关于this question ,我正在尝试使用 cartopy 在特定国家/地区进行着色。复制链接问题中的示例效果很好,但在使用正交投影时会失败。包含 MWE 和图像,正如人们所看到的,德国最终并没有被着色。

(Shapefile数据可以从here获取。)

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.io.shapereader as shpreader

_proj = ccrs.Orthographic(0,0)
#_proj = ccrs.PlateCarree()

_deu = list(shpreader.Reader("shapefiles/DEU_adm_shp/DEU_adm0.shp").geometries())

ax = plt.axes(projection=_proj)
ax.coastlines(resolution='10m', color='k', linewidth=1)

ax.add_geometries(_deu, _proj, edgecolor='black', facecolor='gray', alpha=0.5, zorder=10)

plt.show()

enter image description here

最佳答案

您需要在正确的 CRS 中添加几何图形,这肯定不是正交的。 IIRC 它实际上是盘子方巾。试试这个:

ax.add_geometries(_deu, ccrs.PlateCarree(), edgecolor='black',
facecolor='gray', alpha=0.5, zorder=10)

关于python - Cartopy 中正交投影的 Shapefile 绘图问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41058716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com