【发布时间】:2017-01-27 14:02:02
【问题描述】:
我是 R 新手,有一个关于将核密度图像图与底图相结合的问题: 示例数据集的子集:
spe <- read.table(text = 'Lat Long
-16.664969 52.85978
-16.663191 52.94521
-16.664250 52.85902
-16.664250 52.85902
-16.665164 52.87561
-16.664374 52.98654
-16.663627 53.12452
-16.663479 52.85833
-16.663479 52.85833
-16.663032 52.85823
-16.664142 52.85848
-16.663351 52.85834
-16.663196 52.85829
-16.663339 52.85803
-16.665213 52.85939
-16.664166 52.85912
-16.664166 52.85912
-16.663654 52.85868
-16.663660 52.85868
-16.661111 52.86002', sep = " ", header = T)
为此我做了一个核密度估计和图像:
library(MASS)
f1 <- kde2d(spe$Lat, spe$Long, n = 500,h=0.0005)
image(f1,col= colorRampPalette(c("white", "red"))(15))
现在我想在图片后面放一个谷歌底图,但不知道怎么做,我试过了:
require(ggmap)
mapImageData1 = get_map(location = c(lon = -16.664, lat = 52.859),
color = "color",
source = "google",
maptype = "satellite",
zoom = 16)
ggmap(mapImageData1)
但是我现在如何将地图与具有匹配坐标的图像结合起来?或者尽管 kde2d 有另一种方法可以使用底图上的坐标进行密度估计?
非常感谢!!!希望有人可以在这里帮助我。
【问题讨论】: