4

I'm looking for some help creating heatmaps in R. I'm trying to achieve a result similar to this one:

enter image description here

I’ve Googled this many times but am unable to find a tutorial to give me this result. I seem to have a different definition of a heatmap ;-)

I’ll post a few code snippets below but so far I’ve been able to get a country map using ggmap, adding the long & lat to my data and I’ve been able to display this somewhat as desired, my only issue that remains is to actually show hotspot.

Right now I'm using ggplot2 & ggmap and i've made a dataframe named "df" containing a list of longitude & latitude coordinates (identical addresses are possible, which should be the "heat" part of my heatmap).

I grab the map of, in my case, Belgium as follows:

mapgilbert <- get_map(location = "Belgium", zoom = 7,maptype = "terrain", scale = 2)

next i try to plot my coordinates on there as such:

ggmap(mapgilbert) + geom_point(data = df, aes(x = lon, y = lat, fill = GeoIntake$Freq, colour = "red"), alpha = 0.1, size = 4, shape = 16) + guides(fill=FALSE, alpha=FALSE, size=FALSE)

Can anyone point me in the right direction? The starting point would be a dataframe with some lon/lat info in there, I can easily deduplicate this and add a "frequency" to it.

Luke Stevenson
  • 10,357
  • 2
  • 26
  • 41
MrBramme
  • 63
  • 1
  • 4
  • stat_density_2d is probably what you're looking for. There's what looks like a good example in the R Journal vol 5: http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf – r.bot Apr 27 '15 at 12:12

0 Answers0