0

我有一个印度尼西亚水域盐度的 NetCDF 文件,有 4 个维度(经度、纬度、深度和时间),在此处下载数据:https ://onedrive.live.com/redir?resid=6FFDD661570C7D0A%21177

我想使用levelplotrastesVis包)绘制具有相同范围(最小值 - 最大值)值的盐度数据。不幸的是,我为每个情节获得了不同的价值范围。at=seq(20, 35, 2)没有在我的情节中定义相同的范围?

This is my script:
# Note: Work perfectly after update 'rasterVis package'
# import data
sal <- brick('data.nc', level=1, varname = "salinity")
sal[sal == -32767] <- NA

# colorramp
jet.colors <- colorRampPalette(c('#00007F', 'blue', '#007FFF', 
                                 'cyan','#7FFF7F', 'yellow', '#FF7F00', 
                                 'red', '#7F0000'))

# create levelplot
for (i in 1:5) { # 5 different time in the same depth/level
  png = paste0('D:/sal_',i,'.png')

  png(png, width=2200, height=2200, res=300)
  print(levelplot(subset(sal,i), 
                  col.regions = jet.colors(255),
                  at=seq(20, 34, 1),
                  yscale.components=yscale.raster.subticks,
                  xscale.components=xscale.raster.subticks,
                  margin=FALSE, ylab='latitude', xlab='longitude',
                  main='salinity (psu)'))
  dev.off()
}
4

0 回答 0