请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
12
返回列表 发新帖
楼主: li134

[求助] python 地图

[复制链接]

新浪微博达人勋

 楼主| 发表于 2022-8-17 21:50:59 | 显示全部楼层
易烊启迪 发表于 2022-8-17 21:31
怎么画的,我最近也要画这种地图投影

地图就正常用cartopy画,然后把数据处理成想要处理的网格点,处理成矩阵,然后经纬度也是对应中心点矩阵形式,带到pcolormesh里画。注意输入的经纬度为网格中心经纬度。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-8-17 21:53:53 来自手机 | 显示全部楼层
li134 发表于 2022-08-17 21:50
地图就正常用cartopy画,然后把数据处理成想要处理的网格点,处理成矩阵,然后经纬度也是对应中心点矩阵形式,带到pcolormesh里画。注意输入的经纬度为网格中心经纬度。

嗷嗷好的,您画的代码可以分享下嘛

                               
登录/注册后可看大图
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-8-18 16:14:56 | 显示全部楼层
易烊启迪 发表于 2022-8-17 21:53
嗷嗷好的,您画的代码可以分享下嘛

全部代码不太好分享给你,这一部分是画这种图的代码,你可以参考一下
经纬度处理:
lat = np.arange(2.5, 55, 5)
lon=np.arange(72.5,140, 5)
lons0, lats0 = np.meshgrid(lon, lat)
画图:
plt.rcParams['font.family'] = ['Arial']
SHP = r'E:\data\dilixinxi\3.caotopy地图配置及shp文件读取\china_shp'
fig= plt.figure(figsize=(12,8),dpi=300)
proj = ccrs.PlateCarree(central_longitude=105) #设置一个圆柱投影坐标,中心经度115°E
leftlon, rightlon, lowerlat, upperlat = (70,140,0,55)#设置地图边界范围
'''#####################################10min_N###########'''
ax1 = fig.add_axes([0.06, 0.52, 0.28, 0.28],projection = proj)#figure的百分比,从figure 10%的位置开始绘制, 宽高是figure的80%
                                                              #left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
                                                              #获得绘制的句柄
                                                              #ax1 = fig.add_axes([left, bottom, width, height])
                                                              #ax1.plot(x, y, ‘r’)

ax1.set_extent([leftlon, rightlon, lowerlat, upperlat], crs=ccrs.PlateCarree())#设置边界
ax1.add_feature(cfeature.COASTLINE.with_scale('50m'),linewidth=0.5)#参数scale为地图分辨率,目前支持10m,50m,110m
#f2_ax1.add_feature(cfeature.LAKES, alpha=0.5)
ax1.set_xticks(np.arange(leftlon,rightlon+10,20), crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(lowerlat,upperlat+5,10), crs=ccrs.PlateCarree())
lon_formatter = cticker.LongitudeFormatter()
lat_formatter = cticker.LatitudeFormatter()
ax1.xaxis.set_major_formatter(lon_formatter)
ax1.yaxis.set_major_formatter(lat_formatter)
ax1.set_title('(a) ',loc='left',fontsize =12)
#ax1.set_title( 'm' ,loc='right',fontsize =10)
#填充
china = shpreader.Reader('E:\lidan\data\dilixinxi\\bou2_4m\\bou2_4l.dbf').geometries()
ax1.add_geometries(china,ccrs.PlateCarree(),facecolor='None', edgecolor='black',linewidth=0.5,zorder = 1)#facecolor:表面颜色,edgecolorl:边缘色
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
bounds=[0,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
norl=colors.BoundaryNorm(boundaries=bounds, ncolors=256,extend='both')
norl_res=colors.BoundaryNorm(boundaries=bounds_res, ncolors=256,extend='both')
c=ax1.pcolormesh(lons0,lats0,np.array(n10).reshape(11,14),transform=ccrs.PlateCarree(),norm=norl,alpha=0.75,cmap='jet')#precip3_16lev
plt.show()
其中n10是我处理后的一维变量
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-8-18 18:08:12 来自手机 | 显示全部楼层
li134 发表于 2022-08-18 16:14
全部代码不太好分享给你,这一部分是画这种图的代码,你可以参考一下
经纬度处理:
lat = np.arange(2.5, 55, 5)
lon=np.arange(72.5,140, 5)
lons0, lats0 = np.meshgrid(lon, lat)
画图:
plt.rcParams['font.family'] = ['Arial']
SHP = r'E:\data\dilixinxi\3.caotopy地图配置及shp文件读取\china_shp'
fig= plt.figure(figsize=(12,8),dpi=300)
proj = ccrs.PlateCarree(central_longitude=105) #设置一个圆柱投影坐标,中心经度115°E
leftlon, rightlon, lowerlat, upperlat = (70,140,0,55)#设置地图边界范围
'''#####################################10min_N###########'''
ax1 = fig.add_axes([0.06, 0.52, 0.28, 0.28],projection = proj)#figure的百分比,从figure 10%的位置开始绘制, 宽高是figure的80%
                                                              #left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
                                                              #获得绘制的句柄
                                                              #ax1 = fig.add_axes([left, bottom, width, height])
                                                              #ax1.plot(x, y, ‘r’)

ax1.set_extent([leftlon, rightlon, lowerlat, upperlat], crs=ccrs.PlateCarree())#设置边界
ax1.add_feature(cfeature.COASTLINE.with_scale('50m'),linewidth=0.5)#参数scale为地图分辨率,目前支持10m,50m,110m
#f2_ax1.add_feature(cfeature.LAKES, alpha=0.5)
ax1.set_xticks(np.arange(leftlon,rightlon+10,20), crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(lowerlat,upperlat+5,10), crs=ccrs.PlateCarree())
lon_formatter = cticker.LongitudeFormatter()
lat_formatter = cticker.LatitudeFormatter()
ax1.xaxis.set_major_formatter(lon_formatter)
ax1.yaxis.set_major_formatter(lat_formatter)
ax1.set_title('(a) ',loc='left',fontsize =12)
#ax1.set_title( 'm' ,loc='right',fontsize =10)
#填充
china = shpreader.Reader('E:\lidan\data\dilixinxi\\bou2_4m\\bou2_4l.dbf').geometries()
ax1.add_geometries(china,ccrs.PlateCarree(),facecolor='None', edgecolor='black',linewidth=0.5,zorder = 1)#facecolor:表面颜色,edgecolorl:边缘色
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
bounds=[0,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
norl=colors.BoundaryNorm(boundaries=bounds, ncolors=256,extend='both')
norl_res=colors.BoundaryNorm(boundaries=bounds_res, ncolors=256,extend='both')
c=ax1.pcolormesh(lons0,lats0,np.array(n10).reshape(11,14),transform=ccrs.PlateCarree(),norm=norl,alpha=0.75,cmap='jet')#precip3_16lev
plt.show()
其中n10是我处理后的一维变量

非常感谢,

                               
登录/注册后可看大图
,谢谢,我来看一看
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表