Skip to content

Instantly share code, notes, and snippets.

View mikemahoney218's full-sized avatar
🌲

Michael Mahoney mikemahoney218

🌲
View GitHub Profile
@mikemahoney218
mikemahoney218 / nycflights13_connections.R
Created November 3, 2020 00:53
R script for map of domestric NYC flights in 2013
library(ggplot2)
library(nycflights13)
library(dplyr)
library(sf)
library(maps)
states <- st_as_sf(map("state", plot = FALSE, fill = TRUE))
from <- nycflights13::flights %>%
count(origin, dest, carrier) %>%
@mikemahoney218
mikemahoney218 / katahdin_heightmap_movie.R
Last active November 20, 2020 22:00
Code to create my entry for day 12 of the 2020 30 Day Map Challenge
library(terrainr)
library(rayshader)
katahdin <- tmaptools::geocode_OSM("mt katahdin")
downloaded_tiles <- get_bbox(lat = katahdin$coords["y"],
lng = katahdin$coords["x"]) %>%
set_bbox_side_length(2000) %>%
get_tiles()
katahdin_raster <- raster::raster(downloaded_tiles[[1]])
@mikemahoney218
mikemahoney218 / us_population.R
Created November 15, 2020 21:56
Code to create a map for the #30DayMapChallenge day 20: population
library(ggplot2)
library(dplyr)
library(tigris)
library(tidycensus)
abbr <- state.abb[-c(2, 11)]
state_dat <- vector("list", length(abbr))
names(state_dat) <- abbr
for (i in seq_len(length(state_dat))) {
@mikemahoney218
mikemahoney218 / movement.R
Created November 15, 2020 22:26
Code to create a map of change in US county population, 2013 - 2018, for the 30 Day Map Challenge
library(ggplot2)
library(dplyr)
library(tigris)
library(tidycensus)
abbr <- state.abb[-c(2, 11)]
pop2018 <- vector("list", length(abbr))
names(pop2018) <- abbr
for (i in seq_len(length(pop2018))) {
@mikemahoney218
mikemahoney218 / covid.R
Created November 16, 2020 02:55
Code to create a map of MA COVID-19 cases-per-capita per day for the 30 Day Map Challenge
library(sf)
library(dplyr)
library(tidyr)
library(lubridate)
library(readr)
library(ggplot2)
library(tidycensus)
cases <- read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv") %>%
pivot_longer(cols = matches("^\\d.*"), names_to = "Date", values_to = "cumulative") %>%
@mikemahoney218
mikemahoney218 / tahawus.R
Created November 16, 2020 03:41
Code to create a map for day 19 of the 30 Day Map Challenge: NULL
library(terrainr)
library(magrittr)
downloaded_tiles <- get_bbox(lat = 44.050604, lng = -74.051024) %>%
set_bbox_side_length(8000) %>%
get_tiles(services = c("elevation", "ortho"))
merged_tiles <- lapply(downloaded_tiles, merge_rasters)
raster_to_raw_tiles(merged_tiles[[1]][[1]], "tahawus")
@mikemahoney218
mikemahoney218 / washington_joyplot.R
Last active December 1, 2020 18:01
Code to create a joyplot of Mt. Washington for the 30 Day Map Challenge
library(terrainr) # remotes::install.github("mikemahoney218/terrainr")
library(raster)
library(ggplot2)
library(ggridges)
library(sf)
mt_washington <- tmaptools::geocode_OSM("mt washington")
mt_washington <- get_bbox(lat = mt_washington$bbox[c("ymin", "ymax")],
lng = mt_washington$bbox[c("xmin", "xmax")])
mt_washington <- set_bbox_side_length(mt_washington, 16000)
### Keybase proof
I hereby claim:
* I am mikemahoney218 on github.
* I am mikemahoney218 (https://keybase.io/mikemahoney218) on keybase.
* I have a public key ASDyJEgKGLyyXclb88Qi-XeXGWcUDnbDCG3AJdIsNNHkXgo
To claim this, I am signing this object:
library(terrainr) # remotes::install.github("ropensci/terrainr")
library(sf)
library(ggplot2)
library(progressr)
handlers("progress")
simulated_data <- data.frame(id = seq(1, 100, 1),
lat = runif(100, 44.04905, 44.17609),
lng = runif(100, -74.01188, -73.83493))
@mikemahoney218
mikemahoney218 / make_images.py
Created May 27, 2021 13:21
code for greater_gatsby
from tqdm import trange
from big_sleep import Imagine
from os import listdir, remove, path
gatsby_files = listdir('gatsby')
for file in gatsby_files:
with open(f'./gatsby/{file}') as f:
text = f.readline()