Skip to content

Instantly share code, notes, and snippets.

@blmoore
Created November 16, 2014 16:37
Show Gist options
  • Save blmoore/1f3b5975312804af2c5e to your computer and use it in GitHub Desktop.
Save blmoore/1f3b5975312804af2c5e to your computer and use it in GitHub Desktop.
Generates header image for http://edinbr.org
################################################
# Generates header image for http://edinbr.org #
################################################
library("ggmap")
library("ggplot2")
# grab postcode data
# wget http://www.freemaptools.com/download/full-postcodes/postcodes.zip && unzip
pc <- read.csv("postcodes.csv",
header=T, sep=",", stringsAsFactors=F)
map <- get_map(location="Edinburgh", maptype="terrain", zoom=8, crop=F, color="bw")
p1 <- ggmap(map, extent="device")
pdf("edin.pdf", 14, 14)
# Cut hi-res png slither from this pdf
p1 + stat_binhex(data=pc, bins=120,
aes(x=longitude, y=latitude,
fill=log(..count..)), alpha=I(.5)) +
scale_fill_continuous(high="steelblue4", low="white", space="Lab") +
theme_bw()
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment