我正在尝试使用 NOAA OI SST .nc 文件读取 R 中的温度数据。我每个月都有温度数据,但是,我无法从我想要的坐标中提取月平均温度数据并将其放入数据框中。
我是新手,非常感谢任何帮助或指示。
setwd("~/temperatura/noaa"
prueba<-nc_open("sst.mnmean.nc")
#EXTRAER DATOS
lon<-ncvar_get(prueba,"lon")
lat<-ncvar_get(prueba,"lat")
time<-ncvar_get(prueba,"time")
time=as.Date(time, origin="1800-1-1",tz="UTC")
sst=ncvar_get(prueba,"sst")
unit<-ncatt_get(prueba,"sst","units")$value
我试图制作一个矩阵,但及时我只有数字而不是月份
matriz <- data.frame(cbind(time,lon,lat,sst))
names(matriz) <- c("time","lon","lat","temperature")
time lon lat temperature
1 4352 0.5 89.5 -1.79
2 4383 1.5 88.5 -1.79
3 4414 2.5 87.5 -1.79
4 4442 3.5 86.5 -1.79
5 4473 4.5 85.5 -1.79
6 4503 5.5 84.5 -1.79
7 4534 6.5 83.5 -1.79
8 4564 7.5 82.5 -1.79
9 4595 8.5 81.5 -1.79
像这样