- 积分
- 5966
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-11
- 最后登录
- 1970-1-1
|
发表于 2018-2-2 09:39:30
|
显示全部楼层
你好,我在叠图的时候遇到了点问题,打扰请教一下。第一个是不知道怎么把经纬度网格线去掉(看起来碍眼睛,原谅我的强迫症),mdrawparallels和mdrawmeridians函数似乎都没有提供可以直接操作的方法。第二个不知道怎么叠地图,虽然我单独可以正确画出来地图。网上也没有找到明确的示例程序。我放一下自己的程序和出的图:
- import numpy as np
- import matplotlib.pyplot as plt
- from scipy.io import loadmat
- from matplotlib.patches import Polygon
- from scipy.interpolate import griddata
- from mpl_toolkits.basemap import Basemap
- lonlat=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\lonlat.mat')
- AnnualRain_Ratio=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\AnnualRain_Ratio.mat')
- Rain_Ratio=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\Rain_Ratio.mat')
- StnName=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\StnName.mat')
- sample=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\sample.mat')
- Token=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\Token.mat')
- New_Rain_Ratio=loadmat('C:\Users\CQQXT\Documents\MATLAB\BP_forecast_onebyone\New_Rain_Ratio.mat')
- grid_lon,grid_lat=np.meshgrid(np.arange(105,110.5,0.1),np.arange(28,32.5,0.1))
- lon_lat=np.transpose(np.array([lonlat['lonlat'][:,0],lonlat['lonlat'][:,1]]))
- def PlotCqMap():
- fig=plt.figure()
- ax1=fig.add_axes([0.1,0.1,0.8,0.8])
- bmap=Basemap(llcrnrlon=105,llcrnrlat=28,urcrnrlon=111,urcrnrlat=33)
- shp_info=bmap.readshapefile('F:\\2016\\Youth_Foundation\\CHN_adm_shp\\CHN_adm3','states',drawbounds=False)
- for info, shp in zip(bmap.states_info,bmap.states):
- proid=info['NAME_1']
- if proid=='Chongqing':
- poly=Polygon(shp,facecolor='w',edgecolor='k',lw=0.5)
- ax1.add_patch(poly)
- bmap.drawparallels(np.arange(28,33,2),color='k',labels=[1,0,0,0])
- bmap.drawmeridians(np.arange(105,110,2),color='k',labels=[0,0,0,1])
- return
- for i in range(6):
- plt.subplot(2,3,i+1)
- agency=griddata(lon_lat,AnnualRain_Ratio['AnnualRain_Ratio'][:,i],(grid_lon,grid_lat),method='cubic')
- plt.imshow(agency)
- PlotCqMap
- plt.title('cubic interpolation')
复制代码 |
-
-
|