Reputation: 1086
My problem is that I have some thousand POIs and I'd like to make a geo-heatmap of them, preferably in R. Something like this: http://www.geoindex.hu/wp-content/uploads/Nyiregyhaza-vasarloero-100x100-2015.png
I tried ggmap's qmap + geom_point, but that is not really like it, while qmap + stat_bin2d looks similar, but you cannot really control the color and size of the map-elements.
What package should I use? Is there some wrap-around package for Google's Heatmap Layer? Thanks.
Upvotes: 0
Views: 2473
Reputation: 1411
The ggmap
package can do what you want.
# 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)
Code shamelessly stolen from: https://blog.dominodatalab.com/geographic-visualization-with-rs-ggmaps/
Upvotes: 1