Skip to content

Instantly share code, notes, and snippets.

View ericrobskyhuntley's full-sized avatar

Eric Robsky Huntley ericrobskyhuntley

View GitHub Profile
@ericrobskyhuntley
ericrobskyhuntley / sample.geojson
Created April 25, 2025 16:25
Sample GeoJSON for Testing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ericrobskyhuntley
ericrobskyhuntley / granularFlyin.pde
Created April 16, 2025 22:07
Processing script written as part of the introduction sequence for a series of interviews conducted by members of the Agora: Urban Planning and Design editorial board between September 2013 and January 2014. Relocated from personal github repo.
/**
* Granular FlyIn
*
* Built using Daniel Shiffman's "Explode" sketch as a base.
*
* Animates breaking apart of image, converging on z=0 plane.
* Maps pixels from a 2D image into 3D space.
* Saves exported frames as a numbered series of TIF files.
* Haven't actually looked at this since 2014 so this is
* probably extremely suboptimal.
@ericrobskyhuntley
ericrobskyhuntley / pulsarize.pde
Created April 16, 2025 21:59
Cute Processing script that graphs image intensity (R+G+B) along horizontal axis at designated vertical intervals creating a similar effect to https://github.com/mit-spatial-action/unknown_pleasuR.
String imgPath = "upthenose_color.jpg";
String imgOut = appendSuffix(imgPath, "out");
float imgScale = 0.5; // Scale for the image
int lineStep = 4; // Step for the y-axis
color backgroundColor = color(153, 0, 0); // Background color (R, G, B)
PImage img;
void settings() {
img = loadImage(imgPath);
@ericrobskyhuntley
ericrobskyhuntley / index.html
Last active April 10, 2024 15:01
Demoing functions to offset circles by a data-driven quantity (hack necessary because of lack of data-driven styling on `'circle-translate'`).
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Add a line to a map using a GeoJSON source</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
@ericrobskyhuntley
ericrobskyhuntley / owner_occupied_units.R
Last active September 18, 2023 15:41
R script to approximate the number of units in owner-occupied 2-, 3-, and 4- unit buildings in Somerville.
df <- sf::st_read("M274_parcels_CY22_FY23_sde.gdb", layer = "M274Assess") |>
dplyr::mutate(
simp = dplyr::case_when(
stringr::str_detect(USE_CODE, "^0?101") ~ "101",
stringr::str_detect(USE_CODE, "^0?104") ~ "104",
stringr::str_detect(USE_CODE, "^0?105") ~ "105",
stringr::str_detect(USE_CODE, "^0?109") ~ "109",
stringr::str_detect(USE_CODE, "^0?111") ~ "111",
stringr::str_detect(USE_CODE, "^0?112") ~ "112",
),
@ericrobskyhuntley
ericrobskyhuntley / pums_mobile_homes.R
Last active May 25, 2023 18:46
Script to aggregate PUMS responses to reproduce and extend table characterizing the demographics of mobile home residents found in Esther Sullivan, Manufactured Insecurity Mobile Home Parks and Americans’ Tenuous Right to Place. (Berkeley, CA: University of California Press, 2018). Made for David Tisel for a forthcoming article in the _Review of…
library(tidycensus)
library(dplyr)
library(tidyr)
library(gt)
# vars <- tidycensus::pums_variables %>%
# dplyr::filter(year == 2017, survey == "acs5")
#
# vars_housing <- vars %>%
# dplyr::filter(level == "housing")
@ericrobskyhuntley
ericrobskyhuntley / pair_locator.py
Last active August 30, 2021 04:17
Align aerial imagery from O-D points (current use case is mines and industry headquarters.
import geopandas as gpd
import pandas as pd
import contextily as ctx
from rasterio import open as rioopen
from rasterio import band
from rasterio.mask import mask
from rasterio.plot import reshape_as_image, show
from rasterio.transform import Affine
from rasterio.warp import calculate_default_transform, reproject, Resampling
import rioxarray
---
output:
pdf_document: default
---
# Spatial Multilevel Modeling of Life Expectancy
```{r message=FALSE, warning=FALSE, echo=FALSE}
require('tidycensus')
require('readstata13')
require('stringr')
@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) %>%
@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