【问题标题】:How can I map the regular dataset using coordinates in R?如何使用 R 中的坐标映射常规数据集?
【发布时间】:2011-05-12 19:30:36
【问题描述】:

我有一个这样的数据集

经纬度 mxgYield

38.96152878 -123.5578995 7.925971605

39.24150085 -123.6392975 19.6720449

39.52162933 -123.7214966 19.777747

39.80192947 -123.8044968 12.23218451

40.36297989 -123.9729004 15.00058428

40.64371872 -124.058403 1.443492322

38.74369812 -123.1184998 1.938840925

我正在尝试将 mxgYield 映射为颜色渐变。我应该如何在 R 中做到这一点?

谢谢

【问题讨论】:

标签: r


【解决方案1】:

在数据量上似乎有点弱,但使用 akima 的 interp 函数和基本轮廓绘图函数的组合会成功:

yield <- read.table(textConnection("Lat Lon mxgYield
38.96152878 -123.5578995 7.925971605
39.24150085 -123.6392975 19.6720449
39.52162933 -123.7214966 19.777747
39.80192947 -123.8044968 12.23218451
40.36297989 -123.9729004 15.00058428
40.64371872 -124.058403 1.443492322
38.74369812 -123.1184998 1.938840925"), header=TRUE)
require(akima)
ak.yld <- with( yield, interp(x=Lat, y=Lon, z=mxgYield))
contour(ak.yld)

(在我的屏幕上看起来更漂亮,但您仍然应该看到包含数据的区域的等高线图。)

【讨论】:

  • 谢谢。但我想要的是一张由不同颜色的渐变显示产量的地图。不是等高线图。
  • 现在我想我可以使用 MAPS 包中的图像来做到这一点。非常感谢
  • image(基本函数)也适用于 interp 对象,但对我来说并不好看。也可以使用以下方法为等高线着色:contour(ak.yld, col=1:10) 或使用:image(ak.yld, col=terrain.colors(8) )
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-18
相关资源
最近更新 更多