我正在从basemap迁移到Cartopy,并希望以高分辨率绘制有限区域的海底地形。 在basemap中,我使用ETOPO1_Ice_g_gmt4.grd并根据我在某处找到的文档将其转换为地图坐标。我不知道如何为Cartopy做到这一点。有人能帮忙吗? 干杯,苏奈
更新:Basemap中的代码
地图=基本地图(投影='merc',llcrnrlat=67.2,urcrnrlat=69.5,\
llcrnrlon=8,urcrnrlon=16.5,lat=67.5,)
topoFile = nc.NetCDFFile('/home/sunnje/data/ETOPO1_Ice_g_gmt4.grd','r')
topoLons = topoFile.variables['x'][:]
topoLats = topoFile.variables['y'][:]
topoZ = topoFile.variables['z'][:]
# transform to nx x ny regularly spaced 1km native projection grid
nx = int((map.xmax - map.xmin)/1000.)+1
ny = int((map.ymax - map.ymin)/1000.)+1
topodat = map.transform_scalar(topoZ,topoLons,topoLats,nx,ny)
tyi = np.linspace(map.ymin,map.ymax,topodat.shape[0])
txi = np.linspace(map.xmin,map.xmax,topodat.shape[1])
ttxi, ttyi = np.meshgrid(txi,tyi)
cm = map.contour(ttxi, ttyi, topodat)
首先,这里是一个演示代码及其使用cartopy的输出映射。它使用您指定的投影和贴图范围
要修改代码以绘制数据,只需将(xs、ys、zs)更改为(ttxi、ttyi、topodat)
相关问题 更多 >
编程相关推荐