簡體   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