Two ways to make “heatmaps” of the distributioin of Roman Amphitheaters.

library(curl)
library(ggplot2)
library(raster)
library(rgdal)
library(RColorBrewer)
library(rgl)
library(sp)
library(spatstat)
# See http://
library(cawd)

#plot Roman empire to confirm load
par(mai=c(0,0,0,0))
plot(awmc.roman.empire.200.sp)

# but that's not a very nice projection when done in plot, so...
plot(spTransform(awmc.roman.empire.200.sp, CRS("+init=epsg:3857")))

# ggplot2 makes nice heatmaps and its coord_map() handles WGS84 by default

#first convert to form ggplot2 likes
fortify(awmc.roman.empire.200.sp) -> awmc.roman.empire.200.gg

# do a little imputation to create missing data
ramphs$imputed.capacities <- NA
ramphs$imputed.capacities[!(is.na(ramphs$capacity))] <- ramphs[!(is.na(ramphs$capacity)),]$capacity
ramphs$imputed.capacities[is.na(ramphs$capacity)] <- ramphs[is.na(ramphs$capacity),]$ext.major * 250 # 250 seats per exterior meter
ramphs$imputed.capacities[is.na(ramphs$imputed.capacities)] <- 7000

# the stat_density2d() call is what makes the heatmap
ggplot(ramphs, aes(x = longitude, y = latitude))  +
  coord_map() +
  geom_polygon(data=awmc.roman.empire.200.gg,aes(x=long, y=lat,group=group), colour="purple", fill = "purple", alpha = .5) +
  geom_density2d(aes(fill = ..level..),kernel = "cosine",) +
  geom_point( colour = 'black', size = 2) +
  geom_point(aes(size = capacity), colour = 'red') +
  scale_fill_gradientn(colours=rev(brewer.pal(7,"Spectral")))   +
  theme_bw()