1

这个问题相关,我正在尝试使用 cartopy 在特定国家/地区着色。复制链接问题中的示例可以正常工作,但在使用正交投影时会失败。包括 MWE 和图像,正如人们所看到的,德国最终并没有被着色。

(Shapefile 数据可以从这里获得。)

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()

在此处输入图像描述

4

1 回答 1

2

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

ax.add_geometries(_deu, ccrs.PlateCarree(), edgecolor='black',
                  facecolor='gray', alpha=0.5, zorder=10)
于 2016-12-09T17:41:21.980 回答