我正在尝试在斯堪的纳维亚半岛部分地区的地图上绘制一些气候数据。在下面的代码中,我省略了不相关的部分,重点关注依赖于变换和投影的部分。
使用 PlateCarree() 作为变换和投影关键字都可以,但在该投影中,地图是倾斜的:
dataset_LU = Dataset('data.nc', 'r')
LU = dataset_LU.variables['LU_INDEX'][0,:,:]
lats = dataset_LU.variables['XLAT_M'][0,:,:]
lons = dataset_LU.variables['XLONG_M'][0,:,:]
projection = crs.PlateCarree()
transform = crs.PlateCarree()
fig, axs = plt.subplots(nrows = nrows, ncols = ncolumns,
subplot_kw = {'projection': projection},
figsize = (11,8.5))
cs = axs.contourf(lons, lats, LU, 60, transform=transform,
levels=levels, cmap=cmap2, extend='both')
axs.set_extent(bbox, projection)
当使用 Mercator() 作为变换和投影时,地图显示但没有黑线,海洋颜色错误并且仍然处于倾斜投影上:
dataset_LU = Dataset('data.nc', 'r')
LU = dataset_LU.variables['LU_INDEX'][0,:,:]
lats = dataset_LU.variables['XLAT_M'][0,:,:]
lons = dataset_LU.variables['XLONG_M'][0,:,:]
projection = crs.Mercator()
transform = crs.Mercator()
fig, axs = plt.subplots(nrows = nrows, ncols = ncolumns,
subplot_kw = {'projection': projection},
figsize = (11,8.5))
cs = axs.contourf(lons, lats, LU, 60, transform=transform,
levels=levels, cmap=cmap2, extend='both')
axs.set_extent(bbox, projection)
当使用 Mercator() 作为投影并使用 PlateCarree() 作为变换时,代码需要很长时间,然后显示空图:
dataset_LU = Dataset('data.nc', 'r')
LU = dataset_LU.variables['LU_INDEX'][0,:,:]
lats = dataset_LU.variables['XLAT_M'][0,:,:]
lons = dataset_LU.variables['XLONG_M'][0,:,:]
projection = crs.Mercator()
transform = crs.PlateCarree()
fig, axs = plt.subplots(nrows = nrows, ncols = ncolumns,
subplot_kw = {'projection': projection},
figsize = (11,8.5))
cs = axs.contourf(lons, lats, LU, 60, transform=transform,
levels=levels, cmap=cmap2, extend='both')
axs.set_extent(bbox, projection)
我在这里误解了什么?如何解决该问题并在墨卡托(或任何其他非 PlateCarree)投影上显示我的数据?