从粗分辨率网格插入到较高分辨率网格

时间:2019-12-20 11:54:39

标签: r

我正在尝试将温度(Tas)从粗糙的网格(2.5°x 2.5°)插值到更高分辨率的网格(0.5°x 0.5°)。我的数据采用以下形式:

COARSE = matrix(c(rep(seq(-180, -170, by = 2.5), times = 5), 
            rep(seq(40, 50, by = 2.5), each = 5), 
            rep(seq(6, 10, by = 1), times = 5)),
            nrow = 25, ncol = 3)
colnames(COARSE) = c("Lon", "Lat", "Tas")

FINE = matrix(c(rep(seq(-180, -170.5, by = 0.5), times = 20), 
              rep(seq(40, 49.5, by = 0.5), each = 20), 
            rep(seq(5, 9, by = 1), times = 80)),
            nrow = 400, ncol = 3)
colnames(FINE) = c("Lon", "Lat", "Tas")

输出应为矩阵,前两列是较细网格的Lon和Lat,然后第三列应表示插值到较细网格的粗网格Tas值。

我尝试在Akima软件包中使用双线性函数,但是我不明白它如何有效地适应我的情况。当然上面的例子真的很容易插值吗?在过去几天中,我搜索了很多示例,但感到很困惑。任何建议,不胜感激。

1 个答案:

答案 0 :(得分:0)

也许您可以像这样尝试插值,其中使用了软件包interp2中的二维插值pracma

library(pracma)
FINE[,3] <- interp2(unique(COARSE[,1]),
                    unique(COARSE[,2]),
                    matrix(COARSE[,3],nrow = length(unique(COARSE[,1]))),
                    unique(FINE[,1]),
                    unique(FINE[,2]))

如此

> head(FINE,20)
         Lon Lat Tas
 [1,] -180.0  40 6.0
 [2,] -179.5  40 6.2
 [3,] -179.0  40 6.4
 [4,] -178.5  40 6.6
 [5,] -178.0  40 6.8
 [6,] -177.5  40 7.0
 [7,] -177.0  40 7.2
 [8,] -176.5  40 7.4
 [9,] -176.0  40 7.6
[10,] -175.5  40 7.8
[11,] -175.0  40 8.0
[12,] -174.5  40 8.2
[13,] -174.0  40 8.4
[14,] -173.5  40 8.6
[15,] -173.0  40 8.8
[16,] -172.5  40 9.0
[17,] -172.0  40 9.2
[18,] -171.5  40 9.4
[19,] -171.0  40 9.6
[20,] -170.5  40 9.8