我想将不规则的xyz矩阵插值为栅格,但保留了原始结构的z值范围。
我使用interp
中的akima
:
library("akima")
steps <- 1000
isu <- with(pts, interp(x, y, z, linear=FALSE,extrap = FALSE,
xo=seq(min(x), max(x), length = steps),
yo=seq(min(y), max(y), length = steps),
duplicate="mean"
))
r <- raster(isu)
plot(r)
如下图所示,插值光栅的值不在原始xyz结构的范围内。
c(min(isu$z,na.rm=TRUE),max(isu$z,na.rm=TRUE))
## [1] -2552.964 2378.759
range(pts$z)
## [1] 0 260
为什么?我应该重新调整我的光栅吗?
其中pts是:
structure(list(z = c(136L, 154L, 140L, 181L, 148L, 150L, 162L,
118L, 162L, 111L, 135L, 130L, 120L, 150L, 145L, 128L, 142L, 142L,
210L, 164L, 184L, 170L, 185L, 199L, 174L, 155L, 188L, 125L, 141L,
175L, 196L, 170L, 145L, 86L, 143L, 153L, 152L, 184L, 75L, 198L,
136L, 105L, 128L, 159L, 102L, 138L, 151L, 169L, 121L, 184L, 135L,
143L, 122L, 220L, 155L, 203L, 125L, 184L, 204L, 140L, 168L, 150L,
148L, 128L, 107L, 119L, 97L, 77L, 127L, 114L, 124L, 84L, 89L,
193L, 127L, 82L, 111L, 130L, 118L, 107L, 114L, 141L, 80L, 97L,
163L, 0L, 101L, 140L, 79L, 90L, 100L, 123L, 93L, 97L, 73L, 150L,
174L, 72L, 260L, 167L), x = c(54.339547, 54.9709016, 55.8212876,
51.6600188, 55.755786, 56.1333333, 56.3219, 56.837814, 55.747405,
55.5464299, 55.6481, 105.318756, 50.3837, 54.7115951, 59.9952426,
55.8288889, 55.796538, 56.837814, 51.533269, 59.925345, 59.939039,
55.7580556, 55.8089695, 48.713505, 51.605518, 59.938951, 59.938951,
54.7355004, 54.6246605, 51.7682418, 53.2415041, 55.031958, 55.1598893,
54.7355004, 46.3548889, 54.1966781, 55.755786, 59.939039, 55.6481,
55.750806, 61.6818618, 54.6246605, 53.2061203, 55.88022189, 55.6934,
59.939039, 59.939039, 59.8731001, 55.755786, 55.7534723, 55.755786,
55.755786, 55.755786, 48.772511, 55.7813246, 56.3299177, 43.521792,
44.9132168, 45.665016, 38.1836038, 44.264502, 44.9132168, 42.761209,
44.9132168, 44.264502, 45.946116, 42.35535, 42.41937, 44.425269,
45.521503, 42.050794, 42.050794, 38.18373, 37.3104436, 43.5313513,
44.71501199, 39.0807391, 43.158873, 39.232541, 40.747538, 45.640553,
37.5078011, 37.5078011, 43.881575, 45.7144164, 44.15687, 41.6431026,
41.1054732, 41.645947, 45.529441, 40.997731, 45.1588749, 45.521503,
41.857833, 40.121657, 38.1156193, 44.8378942, 37.1031441, 45.464846,
39.9052746), y = c(48.373489, 73.3937532, 49.0933738, 39.1974105,
37.617633, 47.2333333, 44.0051, 60.596842, 37.591524, 39.4327378,
37.8572, 61.52401, 36.3524, 20.5099722, 30.2554751, 37.6555556,
49.1082, 60.596842, 46.034549, 30.321064, 30.315785, 37.6783333,
37.6379823, 44.502869, 39.222822, 30.343437, 30.343437, 55.9919816,
39.7385714, 55.1037104, 50.2212463, 82.953644, 61.4025803, 55.9919816,
48.0527189, 37.6178285, 37.617633, 30.315785, 37.8572, 37.610207,
50.8127706, 39.7385714, 50.2050851, 37.44934, 37.4911525, 30.315785,
30.315785, 30.2588074, 37.617633, 37.6123527, 37.617633, 37.617633,
37.617633, 44.800186, 37.5772982, 44.0091923, 13.238182, 8.6169507,
9.693546, 15.5542028, 8.436127, 8.6169507, 11.1131708, 8.6169507,
8.436127, 12.46763, 14.40302, 12.106826, 8.848392, 9.597588,
13.922188, 13.922188, 15.5543209, 13.5831419, 13.5489586, 10.634035,
17.1270792, 13.720088, 9.092041, 14.604689, 12.597156, 13.0836215,
13.0836215, 10.773773, 9.5623315, 12.43264, 13.3456679, 16.9106254,
13.347809, 9.041834, 14.156013, 10.7957351, 9.597588, 12.560773,
18.298212, 13.3613758, 11.6204396, 13.9402739, 9.193394, 8.596333
)), .Names = c("z", "x", "y"), class = c("data.table", "data.frame"
), row.names = c(NA, -100L))