更改底图投影会导致数据消失

Changing Basemap projection causes data to disappear

正如标题所说。 我正在绘制海冰浓度数据和此代码:

map = Basemap(projection='cyl', lat_0 = lat_0, lon_0 = lon_0,
          llcrnrlon = llcrnrlon, llcrnrlat = llcrnrlat,
          urcrnrlat = urcrnrlat, urcrnrlon = urcrnrlon,
          area_thresh = 1000., resolution='l')

工作正常。 http://i.imgur.com/8i36gn0.png

但是当我尝试更改投影时:

map = Basemap(projection='npstere',boundinglat=10,lon_0=270,resolution='l')

我刚得到一张空白地图。 http://i.imgur.com/5TazZdC.png

我是不是忘了底图?我虽然改变投影非常简单。

编辑:这是完整代码

import numpy as np
import math as m
import urllib2
import time
import datetime
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
from matplotlib.colors import LinearSegmentedColormap
from mpl_toolkits.basemap import Basemap
from pydap.client import open_url
from pydap.proxy import ArrayProxy
import scipy
from scipy.ndimage.filters import minimum_filter, maximum_filter

data_url_ice = 'http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/noaa.oisst.v2.highres/icec.day.mean.2015.v2.nc'

dataset3 = open_url(data_url_ice)

#############################################################################################
# Get Data
#############################################################################################

# Daily Mean Ice Concentration

Lat_ice = dataset3['lat']
Lon_ice = dataset3['lon']
Time_ice = dataset3['time']
Ice_Conc = dataset3['icec']
Ice_Conc = Ice_Conc[-1,:,:]
Ice_Conc = Ice_Conc.array[:]

Ice_Conc[Ice_Conc < 0] = 0
Ice_Conc = Ice_Conc * 100.

Ice_Conc = Ice_Conc.squeeze()

#############################################################################################
# Colormap
#############################################################################################

vmax_ice = 100.0
cmap_ice = LinearSegmentedColormap.from_list('mycmap', [(0     / vmax_ice, 'white'),    #-40
                                                         (50.   / vmax_ice, 'yellow'), #-20
                                                         (100.   / vmax_ice, 'blue')]    # 20
                                              )

#############################################################################################
# Map Projection Info
#############################################################################################

lat_0 = 0
lon_0 = 0

llcrnrlat = -90. # (1,1)
llcrnrlon = 0. # (1,1)

urcrnrlat = 90. # (720,361)
urcrnrlon = 359. # (720,361)

# Daily Mean Ice Concentration

fig = plt.figure(figsize=(14,14))
ax = fig.add_subplot(1,1,1)
#map = Basemap(projection='ortho', lat_0 = 50, lon_0 = -105,
#              area_thresh = 1000., resolution='i')

map = Basemap(projection='npstere',boundinglat=10,lon_0=270,resolution='l')

#map = Basemap(projection='cyl', lat_0 = lat_0, lon_0 = lon_0,
#              llcrnrlon = llcrnrlon, llcrnrlat = llcrnrlat,
#              urcrnrlat = urcrnrlat, urcrnrlon = urcrnrlon,
#              area_thresh = 1000., resolution='l')

map.drawcoastlines()
map.drawcountries()
map.drawmapboundary()
map.fillcontinents(color='white')

levels = np.linspace(0,100,100)
ticks = [0,10,20,30,40,50,60,70,80,90,100]
iceconc = plt.contourf(Lon_ice,Lat_ice,Ice_Conc,levels,cmap=cmap_ice)

# Set Colorbar Text Color
color_bar = map.colorbar(iceconc)
color_bar.set_ticks(ticks)
cbytick_obj = plt.getp(color_bar.ax.axes, 'yticklabels')
plt.setp(cbytick_obj, color='w')

ax.text(0,1.02,'Sea Ice Concentration (%)\n\n',
        verticalalignment='bottom', horizontalalignment='left',
        transform=ax.transAxes, color='w', fontsize=9).set_clip_on(False)
ax.text(0,1.02,'Satellite Measured Daily Mean\n',
        verticalalignment='bottom', horizontalalignment='left',
        transform=ax.transAxes, color='w', fontsize=9).set_clip_on(False)        

plt.savefig('/home/ice_current.png', facecolor='#3e3e3e', bbox_inches='tight')
plt.close("all")

我认为您忘记了最简单的一行,但是您没有显示大部分代码,所以很难猜到。 即

map = Basemap(projection='cyl', lat_0 = lat_0, lon_0 = lon_0,
          llcrnrlon = llcrnrlon, llcrnrlat = llcrnrlat,
          urcrnrlat = urcrnrlat, urcrnrlon = urcrnrlon,
          area_thresh = 1000., resolution='l')

#valid aproximate coordinates for some map projections
lat = [19.2325]
lon = [-155.3395]

#but the actual map coordinates are
x,y = map(lat, lon)
map.plot(x, y, 'ro', markersize=6)

我相信您的数据仍然存在,但尚未转换为 proper map coordinates。请注意他们在示例中如何使用 m,您的 Basemap 实例在您的示例中被命名为 map,因此请使用它。我认为他们的做法很酷。