如何在 R 中制作地理数据热图?

How do I make a heatmap of geo-data in R?

我的问题是我有几千个兴趣点,我想制作它们的地理热图,最好是在 R 中。像这样:http://www.geoindex.hu/wp-content/uploads/Nyiregyhaza-vasarloero-100x100-2015.png

我尝试了 ggmap 的 qmap + geom_point,但不是很喜欢,而 qmap + stat_bin2d 看起来很相似,但你无法真正控制地图元素的颜色和大小。

我应该使用什么包? Google 的热图层是否有一些环绕包? 谢谢

ggmap 包可以做你想做的事。

# Package source URL: http://cran.r-project.org/web/packages/ggmap/ggmap.pdf
# Data source URL: http://www.geo.ut.ee/aasa/LOOM02331/heatmap_in_R.html

install.packages("ggmap")
library(ggmap)

# load the data
tartu_housing <- read.csv("data/tartu_housing_xy_wgs84_a.csv", sep = ";")

# Download the base map
tartu_map_g_str <- get_map(location = "tartu", zoom = 13)
# Draw the heat map
ggmap(tartu_map_g_str, extent = "device") + geom_density2d(data = tartu_housing, aes(x = lon, y = lat), size = 0.3) + 
  stat_density2d(data = tartu_housing, 
                 aes(x = lon, y = lat, fill = ..level.., alpha = ..level..), size = 0.01, 
                 bins = 16, geom = "polygon") + scale_fill_gradient(low = "green", high = "red") + 
  scale_alpha(range = c(0, 0.3), guide = FALSE)

无耻地窃取了代码:https://blog.dominodatalab.com/geographic-visualization-with-rs-ggmaps/