地理世界地图的极地立体投影

问题描述 投票:1回答:1

我想使用包含低分辨率世界地图(请参阅here)的geopandas作为我的数据的背景。只要我使用例如,这就可以正常工作。 'PlateCarree'预测。

如果我现在想要使用极地立体投影

ccrs.NorthPolarStereo()

要么

ccrs.SouthPolarStereo()

这是行不通的。

我的代码看起来像这样(使用python 3)

import geopandas as gpd
import cartopy.crs as ccrs

crs = ccrs.NorthPolarStereo()
crs_proj4 = crs.proj4_init
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
w = world.to_crs(crs_proj4)
w.plot(facecolor='sandybrown', edgecolor='black',)

任何想法,如果极地立体投影根本不适用于这张地图(如果是这样,为什么?)或我做错了什么?

python geopandas cartopy
1个回答
1
投票

当使用特定的cartopy投影绘图时,最好使用cartopy实际创建matplotlib图形和轴,以确保它知道投影(在技术术语中:确保它是GeoAxes,请参阅https://scitools.org.uk/cartopy/docs/latest/matplotlib/intro.html):

crs = ccrs.SouthPolarStereo()
crs_proj4 = crs.proj4_init
w = world.to_crs(crs_proj4)

fig, ax = plt.subplots(subplot_kw=dict(projection=crs))
w.plot(ax=ax, facecolor='sandybrown', edgecolor='black')

然而,这仍然似乎绘制了超出范围的形状。使用cartopy add_geometries方法,这更好地尊重范围:

fig, ax = plt.subplots(subplot_kw=dict(projection=crs))
ax.add_geometries(w['geometry'], crs=crs, facecolor='sandybrown', edgecolor='black')

enter image description here

这看起来有点奇怪(中间的南极洲非常小),但这似乎是预期的(见qazxsw poi)。

通常,请参阅文档中组合GeoPandas和cartopy的示例:https://scitools.org.uk/cartopy/docs/latest/crs/projections.html#southpolarstereo

© www.soinside.com 2019 - 2024. All rights reserved.