from osgeo import gdal
d=gdal.Open(r'D:\idl\visible temp\c20180106_00.tif')
bandg = d.GetRasterBand(1)
elevationg = bandg.ReadAsArray()
x0, dx, dxdy, y0, dydx, dy = d.GetGeoTransform()
nrows, ncols = elevationg.shape#竖57横52
x1 = x0 + dx * ncols
y1 = y0 + dy * nrows
latst=np.linspace(x0,x1,ncols)
lonst=np.linspace(y0,y1,nrows)
lont, latt = np.meshgrid(latst, lonst)
lon_0t=(x0+x1)/2#计算中心坐标
lat_0t=(y0+y1)/2#计算中心坐标
#m = Basemap(lat_0=lat_0t, lon_0=lon_0t)
map = Basemap(projection = 'cyl',lat_0 = lat_0t, lon_0 = lon_0t,llcrnrlon = x0, llcrnrlat = y1,
urcrnrlon = x1,urcrnrlat = y0,resolution = 'c')#设置显示范围
map.readshapefile('D:\idl\Export_Output3','a')#输入显示矢量文件
#clevs = [0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150,200,250,300,400,500,600,750]
xit, yit = map(lont, latt)#
#cs = map.contourf(xit,yit,elevationg,clevs,cmap=cm.s3pcpn)
levels=map.pcolor(xit,yit,elevationg)#显示图像
map.drawparallels(np.arange(24, 25, 0.15), labels=[True,False,False,True],fontsize=10, rotation=90)#纬度大小
map.drawmeridians(np.arange(117, 119, 0.15), labels=[True,False,False,True],fontsize=10)#经度大小
cbar = map.colorbar(levels, location='right', pad="2%")
这是一个隐藏参数。。。我天用户手册没有这个参数好么!!
附用户手册:
https://matplotlib.org/basemap/api/basemap_api.html#mpl_toolkits.basemap.Basemap.drawparallels
drawparallels(circles, color='k', textcolor='k', linewidth=1.0, zorder=None, dashes=[1, 1], labels=[0, 0, 0, 0], labelstyle=None, fmt='%g', xoffset=None, yoffset=None, ax=None, latmax=None, **text_kwargs)
Draw and label parallels (latitude lines) for values (in degrees) given in the sequence circles.
Keyword | Description |
---|---|
color | color to draw parallels (default black). |
textcolor | color to draw labels (default black). |
linewidth | line width for parallels (default 1.) |
zorder | sets the zorder for parallels (if not specified, uses default zorder for matplotlib.lines.Line2D objects). |
dashes | dash pattern for parallels (default [1,1], i.e. 1 pixel on, 1 pixel off). |
labels | list of 4 values (default [0,0,0,0]) that control whether parallels are labelled where they intersect the left, right, top or bottom of the plot. For example labels=[1,0,0,1] will cause parallels to be labelled where they intersect the left and and bottom of the plot, but not the right and top. |
labelstyle | if set to “+/-”, north and south latitudes are labelled with “+” and “-”, otherwise they are labelled with “N” and “S”. |
fmt | a format string to format the parallel labels (default ‘%g’) or a function that takes a latitude value in degrees as it’s only argument and returns a formatted string. |
xoffset | label offset from edge of map in x-direction (default is 0.01 times width of map in map projection coordinates). |
yoffset | label offset from edge of map in y-direction (default is 0.01 times height of map in map projection coordinates). |
ax | axes instance (overrides default axes instance) |
latmax | absolute value of latitude to which meridians are drawn (default is 80). |
**text_kwargs | additional keyword arguments controlling text for labels that are passed on to the text method of the axes instance (see matplotlib.pyplot.text documentation). |
returns a dictionary whose keys are the parallel values, and whose values are tuples containing lists of the matplotlib.lines.Line2D and matplotlib.text.Text instances associated with each parallel. Deleting an item from the dictionary removes the corresponding parallel from the plot.
手册里没有rotation这个参数好么,其实是继承的关系,手册没有这个参数也可以试试。。。具体什么是继承,百度吧