我正在尝试设置Basemap以使用Cylindrical Equal Area投影并将原点放置在特定的lat / lon(这是为了匹配某些输入x / y数据),但似乎设置 lat_0lon_0 参数什么都不做 .

from mpl_toolkits.basemap import Basemap

# Oklahoma bounds 
# ('o' = origin at corner of Kingfisher/Logan/Canadian/Oklahoma counties)
lats = {'n':  37.1, 's':  33.6,  'c':  35.5, 'o':  35.726}
lons = {'e': -94.4, 'w': -103.0, 'c': -97.5, 'o': -97.674}

buf = 0.05 # plot buffer size (in degrees)

res = 'c' # map shapes resolution

# projection parameters
proj = 'cea' # cylindrical equal area
lat_ts = lats['c'] # true scale at geographic center
lon_0 = lons['o']  # x=0 at counties corner
lat_0 = lats['o']  # y=0 at counties corner

m = Basemap(projection = proj, lat_ts = lat_ts, resolution = res,
            lon_0 = lon_0, lat_0 = lat_0,
            urcrnrlon = lons['e'] + buf, urcrnrlat = lats['n'] + buf,
            llcrnrlon = lons['w'] - buf, llcrnrlat = lats['s'] - buf*4)

然后检查原点给出:

In [15]: m(0, 0, inverse=True)
Out[15]: (-103.05000000000305, 33.399999999963455)

...这是 Map 边界的左下角,而不是我给 lat_0lon_0 的坐标 . 如果我完全省略lat_0和lon_0,我会得到相同的输出 .

起初,我认为CEA投影可能不支持这些参数,我应该手动移动我的数据,但是the docs claim that lat_0 and lon_0 are used by all projections .

作为一种解决方法,我可以设置偏移量来获得预期结果:

offset = m(lon_0, lat_0)
df['x'], df['y'] = (df.x + offset[0], df.y + offset[1]) # where df is a Pandas dataframe with my data

我现在已经在Basemap GitHub存储库中提交了这个问题 . https://github.com/matplotlib/basemap/issues/192