Skip to content

Instantly share code, notes, and snippets.

View ericrobskyhuntley's full-sized avatar
🌹

Eric Robsky Huntley ericrobskyhuntley

🌹
  • MIT Department of Urban Studies and Planning
  • Cambridge, MA
  • 00:38 (UTC -04:00)
View GitHub Profile
@ericrobskyhuntley
ericrobskyhuntley / data.csv
Created April 10, 2018 22:52
Normalized Stacked Barchart
State Under 5 Years 5 to 13 Years 14 to 17 Years 18 to 24 Years 25 to 44 Years 45 to 64 Years 65 Years and Over
AL 310504 552339 259034 450818 1231572 1215966 641667
AK 52083 85640 42153 74257 198724 183159 50277
AZ 515910 828669 362642 601943 1804762 1523681 862573
AR 202070 343207 157204 264160 754420 727124 407205
CA 2704659 4499890 2159981 3853788 10604510 8819342 4114496
CO 358280 587154 261701 466194 1464939 1290094 511094
CT 211637 403658 196918 325110 916955 968967 478007
DE 59319 99496 47414 84464 230183 230528 121688
DC 36352 50439 25225 75569 193557 140043 70648
@ericrobskyhuntley
ericrobskyhuntley / data.csv
Created April 10, 2018 23:08
Stacked Barchart
AL 310504 552339 259034 450818 1231572 1215966 641667
AK 52083 85640 42153 74257 198724 183159 50277
AZ 515910 828669 362642 601943 1804762 1523681 862573
AR 202070 343207 157204 264160 754420 727124 407205
CA 2704659 4499890 2159981 3853788 10604510 8819342 4114496
CO 358280 587154 261701 466194 1464939 1290094 511094
CT 211637 403658 196918 325110 916955 968967 478007
DE 59319 99496 47414 84464 230183 230528 121688
DC 36352 50439 25225 75569 193557 140043 70648
@ericrobskyhuntley
ericrobskyhuntley / README.md
Last active March 22, 2020 00:26 — forked from rgdonohue/README.md
Batch Geocoding Script with GeoPy
@ericrobskyhuntley
ericrobskyhuntley / pct_redlined.R
Last active April 17, 2019 18:01
Percentage Redlined
require('tigris')
require('tidyr')
require('dplyr')
require('sf')
options(tigris_use_cache=FALSE)
tracts <- tracts("MA", year = 2013) %>%
st_as_sf() %>%
mutate(cens_land = as.numeric(ALAND) * 10.76391) %>%
@ericrobskyhuntley
ericrobskyhuntley / index.html
Created March 1, 2019 23:13
Linking Leaflet Layers by ID
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Linking Leaflet Layers by ID</title>
<style>
#map {height: 850px;}
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" />
<!-- Must come after leaflet.css -->
@ericrobskyhuntley
ericrobskyhuntley / floodingmap.js
Last active March 13, 2019 20:57
Leaflet/CARTO Parcel Flooding Map Demonstrating CARTO PostGIS Queries. Files for workshop available here: http://duspviz.mit.edu/resources/carto_demo_s19.zip
var nwCorner = L.latLng(42.341055,-71.07289),
seCorner = L.latLng(42.398887,-70.948951),
bounds = L.latLngBounds(nwCorner, seCorner)
// Create Leaflet map object
var map = L.map('parcelMap',{
center: [42.371353, -71.034150],
zoom: 15,
minZoom: 14,
@ericrobskyhuntley
ericrobskyhuntley / global.R
Created March 15, 2019 20:01
R Shiny with Mapdeck
#
# In this global.R field, we create all objects and run all code
# that we only want to run once when we start our app and that we
# want accessible to all parts of our app. This includes database
# queries (in this case at least), API keys, etc.
#
# First, we load and attach packages. A package must be installed before
# loading; for example, to install RPostgreSQL, we simply type
# install.packages("RPostgreSQL").
#
@ericrobskyhuntley
ericrobskyhuntley / geojson-merge.py
Created March 20, 2019 14:55
Python script to merge all GeoJSON files in a directory into a single GeometryCollection and write as a GeoJSON.
import os
import glob
import geojson
json_dir_name = "./"
json_pattern = os.path.join(json_dir_name,'*.geojson')
file_list = glob.glob(json_pattern)
collection = []
@ericrobskyhuntley
ericrobskyhuntley / generate_mult_grid.py
Last active April 10, 2019 19:40
Generate Grids for Dispersed Study Regions Based on Regional Extents
from qgis import *
import processing
proj_path = QgsProject.instance().readPath("./")
layers = iface.mapCanvas().layers()
for n, i in enumerate(layers):
ext = i.extent()
size = 5280
@ericrobskyhuntley
ericrobskyhuntley / prop_split.R
Created November 13, 2019 16:20
Estimate population adjacent to MBTA stops using Census API and MBTA API.
require('tidyverse')
require('tidycensus')
library('jsonlite')
require('sf')
census_api_key("<yourapikey>")
stops <- fromJSON("https://api-v3.mbta.com/stops/?filter[route]=Red", simplifyVector = TRUE)[[1]]$attributes %>%
st_as_sf(coords = c('longitude', 'latitude')) %>%
st_set_crs(4326) %>%