我试图设置Basemap以使用柱面等面积投影,并将原点放置在特定的lat/lon(这是为了匹配一些输入的x/y数据),但是似乎设置lat_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)
然后检查原点得到:
^{pr2}$…这是地图边界的左下角,而不是我为lat_0
和lon_0
提供的坐标。如果我完全忽略lat_0和lon_0,我得到相同的输出。在
起初,我想也许CEA投影不支持这些参数,我应该手动移动数据,但是the docs claim that ^{
作为解决方法,我可以设置偏移量以获得预期结果:
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
现在,我已将此问题作为一个问题提交到basemapgithub存储库中。 https://github.com/matplotlib/basemap/issues/192
目前没有回答
相关问题 更多 >
编程相关推荐