R - 在纬度和经度网格中绘制 netcdf4 数据 space

R - plot netcdf4 data in lat and lon gridded space

我是新手,所以请原谅我的经验不足。

我想绘制给定 n 天内欧洲的最高气温。

可以在此处访问数据 http://www.ecad.eu/download/ensembles/data/Grid_0.44deg_rot/tx_0.44deg_rot_v16.0.nc.gz(258MB..抱歉)。

这是一个具有 3 个维度和 4 个变量的 netcdf 文件。

这是我所做的:

library(ncdf4)
max_tmp_0_44_deg = "tx_0.44deg_rot_v16.0.nc"
max_tmp_0_44_deg = nc_open(max_tmp_0_44_deg)

# create variables
temp = ncvar_get(max_tmp_0_44_deg, 'tx')
lon = ncvar_get(max_tmp_0_44_deg, 'Actual_longitude')
lat = ncvar_get(max_tmp_0_44_deg, 'Actual_latitude')
time = ncvar_get(max_tmp_0_44_deg, 'time')

如何绘制给定日期最高温度的网格(纬度和经度)?

max_day = temp[,,30]   #subset max temp on the 30th day

那我怎么画max_day

应该很简单,但我还没有找到解决方案。

谢谢

您可以使用image函数:

temp_use <- temp[,,30]
temp_use <- round(temp_use)

n_colors <- length(table(temp_use))
image(temp_use,
    col = heat.colors(n_colors),
    xaxt = "n",
    yaxt = "n")
temp_max <- temp_use == max(temp_use, na.rm = T) & !is.na(temp_use)
temp_max[temp_max == F] <- NA
image(temp_max,
    add = T,
    col = "blue",
    xaxt = "n",
    yaxt = "n")