Skip to content

Instantly share code, notes, and snippets.

View pschmied's full-sized avatar

Peter Schmiedeskamp pschmied

View GitHub Profile
@pschmied
pschmied / knitr-example.Rnw
Last active March 31, 2017 00:53
An example of an xtable and some graphics in knitr w/LaTeX
% I use the memoir class for everything. `texdoc memoir` from your command
% prompt (on Mac & Linux anyway) has all the details. It's better.
\documentclass[11pt,letterpaper,article]{memoir} % for a short document
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{latexsym}
% Useful for Knitr. Otherwise, I use memoir class's 'ctabular' env.
\usepackage{longtable}
\newsubfloat{figure}% Allow subfloats in figure environment
@pschmied
pschmied / obesity-by-state.R
Created November 5, 2013 19:51
Plot of state obesity rates in descending order
# Statewide obesity data
# from http://massey.limfinity.com/data/
library(gdata)
library(ggplot2)
# stringsAsFactors=FALSE is important more often than not.
obesity <- read.xls("http://massey.limfinity.com/data/obesity.xls",
sheet=1, stringsAsFactors=FALSE)
@pschmied
pschmied / filegdb.rb
Last active December 23, 2015 06:59
Homebrew formula to install ESRI FileGDB support. This package can be installed via this gist's URL. GDAL can then be installed with FGDB support either by modifying the GDAL formula, or by specifying the `--enable-unsupported` option to the GDAL build.
require 'formula'
# ESRI FileGDB support. This recipe can download the file from ESRI,
# however, you must sign into the ESRI support site and agree to their
# licensing terms from a webbrowser.
class Filegdb < Formula
homepage 'http://www.esri.com/software/arcgis/geodatabase/interoperability'
url 'http://downloads2.esri.com/Software/FileGDB_API_1_3-64.zip'
sha1 '95ba7e3da555508c8be10b8dbb6ad88a71b03f49'
@pschmied
pschmied / big-clip.R
Last active December 20, 2015 15:19
Clip a big number of parcels to the University District. All data downloaded from wagda.lib.washington.edu (must have netid to download)
# install.packages(c("rgdal", "rgeos", "ggmap", "maptools"))
library(rgdal)
library(rgeos)
library(ggmap)
library(maptools)
# Read the shapefile with OGR. Punctuation matters: No trailing slash
# on the dsn, and no .shp on the layer
udist <- readOGR(dsn="/Users/peter/Downloads/clip",
layer="unidstuc")
@pschmied
pschmied / zone-to-zone-travel
Created July 1, 2013 18:39
I whipped this up to validate zone-to-zone travel times and distances from our travel model. This takes a shapefile of zone centroids and queries Google for a random sampling of origin and destination pairs.
# You may need to install a couple libraries before loading them:
# install.packages(c("ggmap", "plyr", "rgdal"))
library(ggmap)
library(plyr)
library(rgdal)
# Here we read in a shapefile containing the centroids of our TAZs
zonecentroids <- readOGR(dsn="/path/containing/shapefile/no/final/slash",
layer="shapefile-containing-points")