0

所以我对 R 很陌生,我目前正在使用 netcdf 数据来制作地中海地区平均气温的地图(数据附后)。但是,我似乎对最终图像有问题,因为经纬度似乎与实际的映射网格相去甚远。不确定最后一句话的措辞是否正确,但我也附上了一张图片和代码。

nc<-nc_open(fn)
print(nc)
dat<-ncvar_get(nc, attributes(nc$var)$names[1])

dim(dat)
lat = ncvar_get(nc, "lat")
lon = ncvar_get(nc, "lon")
air = ncvar_get(nc, "air")
time = ncvar_get(nc, "time")
average <- rowMeans(air, dims = 2)
x = seq(-10, 40, length.out = nrow(air))
y = seq(1, 50.0, length.out = ncol(air))
filled.contour(x,y,average, color = terrain.colors, asp = 1)
data(wrld_simpl)
plot(wrld_simpl, add = TRUE)
map("world2", add = TRUE)

#NOTE - ggplot 没有工作,因为我得到了以下错误,所以我使用了filled.contour

预期增加“x”和“y”值

以下是我得到的图像:[1]:https ://i.stack.imgur.com/pLT2d.png

谷歌驱动器链接有数据: https ://drive.google.com/drive/folders/1nrj0aE68YFRUU7NhPhyFL0aciln2FeMN?usp=sharing

想获得一些关于代码的帮助,以及我似乎出错/或遗漏一些行的地方......

4

0 回答 0