我在印度尼西亚水中有一个含有4维度(lon,lat,深度和时间)的盐度的NetCDF文件。如何从我的数据创建每周复合创建 在此处下载数据:https://onedrive.live.com/redir?resid=6FFDD661570C7D0A%21177 输出地图:https://onedrive.live.com/redir?resid=6FFDD661570C7D0A%21176
我想将栅格转换为矢量并使用apply来获取均值,但是我有问题使用rasterVis
答案 0 :(得分:0)
用你的例子,也不是很复杂:
# load needed librairies
library(rasterVis)
# open the data
salinity <- brick("data.nc", varname = "salinity")
salinity
# class : RasterBrick
# dimensions : 61, 61, 3721, 5 (nrow, ncol, ncell, nlayers)
# resolution : 0.08333333, 0.08333333 (x, y)
# extent : 104.9583, 110.0417, -5.041667, 0.04166667 (xmin, xmax, ymin, ymax)
# coord. ref. : +proj=longlat +datum=WGS84
# data source : data.nc
# names : X252331200, X252417600, X252504000, X252590400, X252676800
# z-value : 252331200, 252417600, 252504000, 252590400, 252676800
# varname : salinity
# level : 1
# Calculate the mean
m.salinity <- mean(salinity)
m.salinity
# class : RasterLayer
# dimensions : 61, 61, 3721 (nrow, ncol, ncell)
# resolution : 0.08333333, 0.08333333 (x, y)
# extent : 104.9583, 110.0417, -5.041667, 0.04166667 (xmin, xmax, ymin, ymax)
# coord. ref. : +proj=longlat +datum=WGS84
# data source : in memory
# names : layer
# values : 18.85652, 31.84299 (min, max)