如何从连续 5 天创建每周综合

How to create weekly composite from 5-consecutive day

我有一个包含 4 个维度(经度、纬度、深度和时间)的印度尼西亚水中盐度的 NetCDF 文件。如何根据我的数据创建每周合成 在此处下载数据:https://onedrive.live.com/redir?resid=6FFDD661570C7D0A%21177 在此处输出地图:https://onedrive.live.com/redir?resid=6FFDD661570C7D0A%21176

我想将栅格转换为矢量并使用 apply 来获取平均值,但是我在使用 rasterVis

绘制矢量数据时遇到问题

用你的例子,也不复杂:

# 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)