【发布时间】:2021-10-29 01:23:13
【问题描述】:
跟随another Q&A,我正在地球球上绘制非洲大陆的国家:
import cartopy
import cartopy.crs as ccrs
from matplotlib import pyplot as plt
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
africa = world[(world['continent'] == 'Africa')]
latlon_proj = ccrs.PlateCarree()
axis_proj = ccrs.Mollweide()
ax = plt.axes(projection=axis_proj)
ax.stock_img()
for ea in africa['geometry']:
feat = cartopy.feature.ShapelyFeature(
[ea],
latlon_proj,
facecolor="lime",
edgecolor='black',
lw=0.2
)
ax.add_feature(feat)
plt.show()
但是,当我将latlon_proj 和axis_proj 更改为ccrs.Orthographic() 时,非洲大陆消失了:
import cartopy
import cartopy.crs as ccrs
from matplotlib import pyplot as plt
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
africa = world[(world['continent'] == 'Africa')]
latlon_proj = ccrs.Orthographic()
axis_proj = ccrs.Orthographic()
ax = plt.axes(projection=axis_proj)
ax.stock_img()
for ea in africa['geometry']:
feat = cartopy.feature.ShapelyFeature(
[ea],
latlon_proj,
facecolor="lime",
edgecolor='black',
lw=0.2
)
ax.add_feature(feat)
plt.show()
更改CCRS时如何保留非洲大陆?
【问题讨论】: