【问题标题】:Is there a way to get matplotlib's Basemap using North Polar Stereographic Projection to plot a range of lat/lons that doesn't include the pole?有没有办法使用北极立体投影来绘制不包括极点的纬度/经度范围来获取 matplotlib 的底图?
【发布时间】:2020-11-02 23:44:40
【问题描述】:

目前,情节给了我这个:

使用:

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# setup north polar stereographic basemap.
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0. Default value of lat_ts
# (latitude of true scale) is pole.
m = Basemap(projection='npstere',boundinglat=55,lon_0=-47,resolution='l') #llcrnrlon=-55.,llcrnrlat=60.,urcrnrlon=-40.,urcrnrlat=65.,
#x,y = m(lon2,lat2)
m.drawcoastlines()
m.fillcontinents(color='white',lake_color='aqua')
# draw parallels and meridians.
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
m.drawmapboundary(fill_color='aqua')
# draw tissot's indicatrix to show distortion.
ax = plt.gca()
for y in np.linspace(m.ymax/20,19*m.ymax/20,10):
    for x in np.linspace(m.xmax/20,19*m.xmax/20,10):
        lon, lat = m(x,y,inverse=True)
        poly = m.tissot(lon,lat,2.5,100,\
                        facecolor='green',zorder=10,alpha=0.5)
plt.title("North Polar Stereographic Projection")
plt.show()

我希望能够放大格陵兰岛的一部分,换句话说,能够将地图的边界角设置为特定的纬度和经度。这可能吗?当前投影太小了。

我想要类似这段代码使用 Lambert Conformal Conic 给我的东西

m = Basemap(llcrnrlon=-60.,llcrnrlat=60.,urcrnrlon=-40.,urcrnrlat=70.,
            projection='lcc',lat_1=20.,lat_2=40.,lon_0=-60.,
            resolution ='l',area_thresh=1000.)
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary(fill_color='#99ffff')
m.fillcontinents(color='#cc9966',lake_color='#99ffff')
m.drawparallels(np.arange(10,70,20),labels=[1,1,0,0])
m.drawmeridians(np.arange(-100,0,20),labels=[0,0,0,1])
plt.title('ICESAT2 Tracks in Greenland')
plt.show()

这给出了:

当然是在北极立体投影中。有什么想法吗?

【问题讨论】:

    标签: python python-3.x matplotlib matplotlib-basemap polar-coordinates


    【解决方案1】:

    使用 Matplotlib 的底图无法实现您的要求。您应该开始改用cartopy。这是一个cartopy可以绘制你需要的地图的例子。

    import matplotlib.pyplot as plt
    import cartopy.crs as ccrs
    import cartopy
    import cartopy.feature as cfeature
    
    fig = plt.figure(figsize=(5, 8))
    ax = fig.add_subplot(111, projection=ccrs.NorthPolarStereo(central_longitude=-47))     
    
    ax.set_extent([-55, -42, 59, 70], crs=ccrs.PlateCarree())
    
    resol = '50m'  # use data at this scale
    land = cartopy.feature.NaturalEarthFeature('physical', 'land', \
        scale=resol, edgecolor='k', facecolor=cfeature.COLORS['land'])
    ocean = cartopy.feature.NaturalEarthFeature('physical', 'ocean', \
        scale=resol, edgecolor='none', facecolor=cfeature.COLORS['water'])
    
    # plot sequence is important
    ax.add_feature(ocean, linewidth=0.2 )
    ax.add_feature(land, facecolor='green')
    
    ax.set_title('central_longitude on -47 $^\circ$W')
    
    # for cartopy version 0.18 only
    ax.gridlines(draw_labels=True, linewidth=0.5, linestyle='--', color='black')
    
    plt.show()
    

    输出图:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-29
      • 1970-01-01
      • 2019-07-26
      • 2015-10-05
      • 1970-01-01
      • 2023-02-20
      • 2021-04-03
      • 1970-01-01
      相关资源
      最近更新 更多