Skip to content

Instantly share code, notes, and snippets.

@andrewbtran
Created August 7, 2016 00:09
Show Gist options
  • Save andrewbtran/7f2ba081d5f96af182463f0521b8a3c3 to your computer and use it in GitHub Desktop.
Save andrewbtran/7f2ba081d5f96af182463f0521b8a3c3 to your computer and use it in GitHub Desktop.
Making another choropleth with an additional layer
townborders <- readOGR(dsn="shapes", layer="ctgeo")
townborders_only <- townborders
townborders<- fortify(townborders, region="NAME10")
# Subset the town borders to just Hamden since that's the department we're looking at
town_borders <- subset(townborders, id=="Hamden")
tm_ct <- ggplot() +
geom_polygon(data = total_map, aes(x=long, y=lat, group=group, fill=total), color = "black", size=0.2) +
geom_polygon(data = town_borders, aes(x=long, y=lat, group=group, fill=total), color = "black", fill=NA, size=0.5) +
coord_map() +
scale_fill_distiller(type="seq", trans="reverse", palette = "Reds", breaks=pretty_breaks(n=10)) +
theme_nothing(legend=TRUE) +
labs(title="Where Hamden police conduct traffic stops", fill="")
print(tm_ct)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment