繁体   English   中英

有没有办法使用北极立体投影到 plot 一系列不包括极点的纬度/经度来获取 matplotlib 的底图?

[英]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?

目前,plot 给了我这个:

在此处输入图像描述

使用:

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

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

我想要类似这段代码使用 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()

这使:

在此处输入图像描述

但当然是在北极立体投影中。 有任何想法吗?

Matplotlib 的底图无法满足您的要求。 您应该开始改用cartopy 这是一个例子,cartopy 可以 plot map 你需要。

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

Output plot:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM