Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Popat rmnppt

View GitHub Profile
@rmnppt
rmnppt / shapeToDf.R
Created Sep 9, 2016
Script that takes a .shp file as an input and outputs a dataframe with the polygon information.
View shapeToDf.R
# process shapefile data
library(rgdal) # requires sp, will use proj.4 if installed
library(gpclib)
library(maptools)
library(ggplot2)
library(plyr)
gpclibPermit()
shpToDf <- function(directory, layer) {
map <- readOGR(dsn=directory, layer=layer)
@rmnppt
rmnppt / UKCities.R
Created Sep 7, 2015
uk cities with transparency mapped to population size
View UKCities.R
library(ggplot2)
library(magrittr)
library(dplyr)
library(maps)
data("world.cities")
world.cities %>%
filter(country.etc == "UK") %>%
ggplot(aes(x = long, y = lat, alpha = pop)) +