Skip to content

Instantly share code, notes, and snippets.

@ahalterman
Created August 30, 2013 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahalterman/6393851 to your computer and use it in GitHub Desktop.
Save ahalterman/6393851 to your computer and use it in GitHub Desktop.
Script for reproducing map of August 29, 2013 GDELT coverage. Orthogonal map projection, centered on Cairo.
# Author: Andrew Halterman. 30 August 2013
# R script for reproducing map of August 29, 2013 GDELT coverage
# Orthogonal map projection, centered on Cairo
# This assumes that you have your GDELT data stored in a SQLite database.
# For instructions on setting up SQLite and dplyr, see http://gdeltblog.wordpress.com/2013/08/29/subsetting-and-aggregating-gdelt-using-dplyr-and-sqlite/
library(dplyr)
library(RSQLite)
library(RSQLite.extfuns)
library(ggplot2)
library(mapproj)
daily.db <- source_sqlite("/Users/andyhalterman/gdelt.db","GDELT_DAILYUPDATES")
today <- filter(daily.db, SQLDATE == 20130829)
today <- select(today, ActionGeo_Lat, ActionGeo_Long)
today <- group_by(today, ActionGeo_Lat, ActionGeo_Long)
today <- summarise(today, count=n())
world <- map_data("world")
worldmap <- ggplot(world, aes(x=long, y=lat, group=group)) + geom_polygon(fill="black", colour="black")
worldmap + coord_map("ortho", orientation=c(30, 33, 0)) + geom_point(data=today, aes(x=ActionGeo_Long, y=ActionGeo_Lat, size=count, group=1), color="red", alpha=.7) + theme(panel.background = element_rect(fill='white', colour='white')) + ggtitle("GDELT Event Coverage, August 29, 2013 \n") + theme(text=element_text(family="Helvetica Neue Light",color="#6E9C27", size=14))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment