gpt4 book ai didi

R 水平图和插值

转载 作者:行者123 更新时间:2023-12-04 15:46:22 25 4
gpt4 key购买 nike

这个问题不太可能对任何 future 的访客有帮助;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛适用,visit the help center .




8年前关闭。




几天前,我设法在脚本中使用以下命令使用插值制作了水平图:

levelplot(jan~lon*lat,APM,main="Jan",panel=panel.levelplot.raster,interpolate=T)

我不小心没有保留那个 session ,只有脚本,所以我不可能通过历史记录并恢复我使用过的所有命令。

现在,在加载latticeExtra 后,相同的命令会生成一个空图。另一方面,省略指令的最后两个元素,即:
levelplot(jan~lon*lat,APM,main="Jan")

图形已绘制。

我想在表面进行插值,但出了点问题
panel=panel.levelplot.raster

加载 rasterVis 时会发生相同的行为。
我想我错过了一些东西......有什么帮助吗?

数据具有以下结构:
> head(APM)
lat lon jan feb mar apr may jun jul aug sep oct nov dec
1 -18.5 10.5 29.7 28.8 25.6 25.6 26.8 29.9 35.5 46.8 35.5 27.5 27.5 27.9
2 -17.5 10.5 28.8 29.8 26.3 26.2 27.8 31.6 39.7 63.1 40.4 27.6 27.6 28.3
3 -16.5 10.5 28.7 30.0 26.9 26.8 28.6 32.1 41.1 109.4 42.8 29.7 28.9 29.4
4 -15.5 10.5 28.4 29.5 27.5 26.9 29.1 34.2 46.4 109.5 40.8 29.7 29.7 28.5
5 -14.5 10.5 28.2 29.3 27.4 27.8 27.8 42.8 60.7 104.3 49.1 29.4 28.8 28.6
6 -13.5 10.5 27.8 28.4 27.7 28.3 29.8 41.2 102.8 105.7 47.8 29.5 28.5 28.0

按纬度和经度列出的总共 224 个单元格:
> dput(APM)
structure(list(lat = c(-18.5, -17.5, -16.5, -15.5, -14.5, -13.5,
-12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5,
-16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5,
-7.5, -6.5, -5.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5,
-11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5, -16.5,
-15.5, -14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5,
-5.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5,
-10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5, -16.5, -15.5,
-14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5,
-18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
-9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5, -16.5, -15.5, -14.5,
-13.5, -12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5,
-17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5, -9.5,
-8.5, -7.5, -6.5, -5.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5,
-12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5,
-16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5,
-7.5, -6.5, -5.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5,
-11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5, -16.5,
-15.5, -14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5,
-5.5, -18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5,
-10.5, -9.5, -8.5, -7.5, -6.5, -5.5, -18.5, -17.5, -16.5, -15.5,
-14.5, -13.5, -12.5, -11.5, -10.5, -9.5, -8.5, -7.5, -6.5, -5.5,
-18.5, -17.5, -16.5, -15.5, -14.5, -13.5, -12.5, -11.5, -10.5,
-9.5, -8.5, -7.5, -6.5, -5.5), lon = c(10.5, 10.5, 10.5, 10.5,
10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 11.5,
11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5, 11.5,
11.5, 11.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5,
12.5, 12.5, 12.5, 12.5, 12.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5,
13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 14.5, 14.5, 14.5,
14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5,
15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5,
15.5, 15.5, 15.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 16.5,
16.5, 16.5, 16.5, 16.5, 16.5, 16.5, 17.5, 17.5, 17.5, 17.5, 17.5,
17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 17.5, 18.5, 18.5,
18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5, 18.5,
18.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5, 19.5,
19.5, 19.5, 19.5, 19.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5,
20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, 21.5, 21.5, 21.5, 21.5,
21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 21.5, 22.5,
22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5, 22.5,
22.5, 22.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5, 23.5,
23.5, 23.5, 23.5, 23.5, 23.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5,
24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 24.5, 25.5, 25.5, 25.5,
25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5, 25.5
), jan = c(29.7, 28.8, 28.7, 28.4, 28.2, 27.8, 28, 29.4, 30.3,
32.5, 33.2, 33.5, 33.1, 34.3, 28.4, 29.4, 29.6, 29, 28.9, 28.8,
28.5, 28.9, 29.9, 31, 32.2, 32.9, 35.8, 37.4, 30, 27.4, 29.6,
30, 28.4, 30.6, 30.4, 29.9, 30.2, 31.3, 33.9, 35.5, 35.8, 34.5,
30.3, 23.8, 25.2, 23.2, 22.9, 24, 27.2, 29.3, 31.6, 32.3, 31,
31.4, 37.3, 37.4, 24.9, 25.1, 23.4, 21.2, 23.5, 22.8, 23.5, 24.5,
26, 27.7, 28.6, 33.3, 37.3, 40.7, 37.9, 38.5, 27.1, 22.5, 24.7,
23.3, 24.7, 24.8, 26.6, 27.4, 30.7, 33.9, 35.9, 37.6, 30.7, 29.5,
26.6, 24.1, 24.1, 25.4, 25.4, 25.7, 28, 28.2, 32.9, 36.3, 35.2,
40.4, 22.7, 25.5, 26.5, 24.6, 24.3, 24, 25.8, 26.7, 29.4, 31.8,
35.4, 38, 37.4, 41.3, 22.2, 23.7, 26.8, 25.8, 25.3, 24, 25.1,
26.9, 29.6, 31.8, 34.4, 35.6, 39.3, 40.1, 26.2, 26.2, 26, 25.8,
25.3, 23.2, 24.5, 25.9, 26.9, 30.8, 33.3, 38.3, 40.2, 41.2, 26.9,
26.4, 27.1, 23.1, 22.9, 24, 28.5, 26.9, 27.1, 31, 32.7, 36.6,
38, 41.6, 26.6, 27.2, 27.3, 26, 23.6, 25.8, 33.2, 33.8, 25.8,
28.1, 31.6, 34.7, 35.3, 38.5, 27.3, 28.1, 28.6, 27, 31.5, 31.8,
29.9, 27.6, 25.4, 28.4, 29.8, 32.2, 36.4, 36.8, 28.2, 26.2, 27.3,
27, 27.1, 23.7, 23.5, 25.3, 26.1, 29, 29.3, 29.3, 36.4, 35.1,
24.2, 25.1, 23.5, 23.1, 24, 24.2, 24.3, 26.7, 26.7, 26.8, 29.3,
30.4, 33.3, 33.4, 24.8, 24.3, 24.5, 24.8, 26.1, 24.6, 25, 25.3,
27.2, 26.8, 28.9, 30.5, 31.2, 33.1), feb = c(28.8, 29.8, 30,
29.5, 29.3, 28.4, 28.6, 28.7, 28.7, 28.5, 29.4, 32.2, 34.4, 37.4,
29.4, 30.5, 30.8, 30.7, 29.6, 28.3, 28, 28.4, 28.4, 29, 29.5,
31.4, 33.3, 37.1, 31.7, 26.5, 29.8, 30.4, 28.4, 28.9, 27.7, 27.8,
29.3, 30, 30.4, 31.7, 32.9, 34.7, 29.1, 23.5, 24.2, 23.3, 22.7,
23.6, 25.4, 26.4, 27.7, 28.1, 26.9, 27.5, 30.4, 31.6, 22.3, 24.7,
23.7, 21.2, 23.4, 22.5, 22.3, 21.7, 23.2, 23.3, 23.2, 27.5, 31.6,
34, 33, 33.3, 26.3, 22.5, 23.9, 24, 24.5, 23.7, 24.2, 24.5, 25.4,
27.8, 31, 33.4, 29.3, 27.5, 24.7, 23.2, 23.5, 24.7, 25.7, 25.4,
25.8, 25.6, 27.2, 30.7, 30.4, 35, 21.4, 23.3, 24.1, 24.7, 25.2,
25.2, 25.6, 25.9, 27.7, 26.9, 30.1, 31.5, 32, 34.5, 20.2, 22.4,
24.9, 25.1, 25.3, 25.5, 24.1, 25.8, 26.2, 28.4, 29.3, 30.9, 33.5,
35.6, 24.3, 24.2, 24, 24.5, 24.9, 24.7, 23.8, 25, 26.2, 27.1,
29.9, 31.3, 34.6, 34.7, 25.3, 23.6, 24.9, 22.6, 23.1, 23.1, 25.3,
26.8, 24.9, 25.1, 28.1, 30.7, 32.1, 34.2, 24, 23.4, 24.6, 25.6,
24.9, 26.4, 30.6, 31.2, 22.2, 23.9, 27.6, 30.8, 29.1, 29.7, 24,
23.6, 25.4, 25.8, 29.9, 29.5, 27.2, 26.3, 23.5, 24.5, 25.6, 27,
28.9, 28.3, 24.4, 22, 23.4, 24.9, 25.4, 22.7, 23, 23, 22.4, 23.7,
24.6, 24.9, 29.8, 28.5, 21.3, 22.8, 21.3, 21.1, 21.7, 22.8, 24.4,
23.2, 23.3, 22.4, 25.4, 26.3, 27.3, 27.1, 22.8, 22.1, 21.4, 21.9,
24.1, 24.1, 26, 23.5, 23.8, 22.5, 23, 24.9, 26.5, 28)), .Names = c("lat",
"lon", "jan", "feb"), row.names = c(NA,
-224L))

最佳答案

以下在 R 的新交互式 session 中生成一个图

APM <- results of dput(APM) from the OP

library(latticeExtra)

levelplot(jan~lon*lat,APM,main="Jan",panel=panel.levelplot.raster,interpolate=T)

或者
levelplot(jan~lon*lat,APM,main="Jan",interpolate=TRUE, useRaster = TRUE)

interpolation works!!

如果这对您不起作用,请检查您是否拥有相关软件包的最新版本;例如,
R version 2.15.2 (2012-10-26)
latticeExtra_0.6-24
lattice_0.20-10
RColorBrewer_1.0-5

如果问题仍未解决,则此帖子中还有其他未提及的内容。

关于R 水平图和插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13251200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com