Lesson 3: Working with Heatmaps and Plots over Polygons

by David Beskow

In this lesson we are going to learn how to create a contour heatmap of spatial point data as well as create pie plots positioned on the centroid of a polygon.

Contour Heat Maps with ggmap

A contoured heat map is another way to demonstrate data density, especially if you do not have or do not desire to create a heatmap over a shapefile (like the country’s provinces). The contour heatmap uses two-dimentsional kernel density estimation in order to create the contoured heatmap of the spatial point data. Think of this as a histogram in two dimensions

Below we demonstrate how to do this using the crime data

library(ggmap) ##load the ggmap package so we can access the crime data
data(crime) ##load the crime data