Create a country map using R

I am looking for some help with creating heatmaps in R. I am trying to achieve a result similar to this:

enter image description here

Ive googled this many times but I cannot find a tutorial to give me this result. I seem to have a different definition of a heatmap :-)

Posted some code snippets below but so far I've managed to get a country map using ggmap adding long and lat to my data and I've been able to display this as desired, my only problem that remains is to actually show the hot point.

Right now I am using ggplot2 and ggmap and I have created a dataframe named "df" containing a list of coordinates and longitudes cooordinates (identical addresses are possible, which should be the "thermal" part of my heatmap).

I take a card, in my case, Beglium like this:

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

      

Next I try to plot my coordinates 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 data frame with some lon / lat data, I can easily defuse that and add a "frequency" to it.

+3


source to share





All Articles