Skip to content

Instantly share code, notes, and snippets.

View mikemahoney218's full-sized avatar
🌲

Michael Mahoney mikemahoney218

🌲
View GitHub Profile
@mikemahoney218
mikemahoney218 / 20211112.R
Created November 9, 2021 02:57
Code for my map for day 12 of the 2021 30 Day Map Challenge (November 12 2021: "Population")
library(sf)
library(tidycensus)
library(ggplot2)
library(dplyr)
acs_pop <- get_acs(
geography = "block group",
variables = "B01003_001",
state = "MA",
year = 2019,
@mikemahoney218
mikemahoney218 / 20211111.R
Created November 9, 2021 02:16
Code for my map for day 11 of the 30 Day Map Challenge on November 11, 2021 ("3D")
library(terrainr)
library(sf)
library(progressr)
handlers("progress")
Washington <- tmaptools::geocode_OSM("Mount Washington")
Washington <- Washington$coords
Washington <- data.frame(
lat = Washington[["y"]],
lng = Washington[["x"]]
@mikemahoney218
mikemahoney218 / 20211110.R
Created November 6, 2021 22:04
Code for my map for the 30 Day Map Challenge on November 10, 2021 ("Raster")
library(terrainr)
library(raster)
library(sf)
library(ggplot2)
library(scico)
Marcy <- tmaptools::geocode_OSM("Mount Marcy")
Marcy <- st_as_sf(as.data.frame(t(as.data.frame(Marcy$coords))), coords = c("x", "y"), crs = 4326)
site_bbox <- set_bbox_side_length(Marcy, 10, "km")
@mikemahoney218
mikemahoney218 / 20211109.R
Last active November 9, 2021 20:45
Code for my map for the 30 Day Map Challenge on November 09, 2021 ("Monochrome")
library(raster)
library(rayshader)
library(terrainr)
library(sf)
Rainier <- tmaptools::geocode_OSM("Mount Rainier")
Rainier <- st_as_sf(as.data.frame(t(as.data.frame(Rainier$coords))), coords = c("x", "y"), crs = 4326)
zscale <- 5
Rainier <- set_bbox_side_length(
Rainier,
@mikemahoney218
mikemahoney218 / rs.R
Last active August 26, 2021 18:38
quick rayshader example
library(lidR)
library(raster)
library(rayshader)
# Set the color scale
color_pal <- function(n = 255, bias = 1) {
pal <- colorRampPalette(
RColorBrewer::brewer.pal(9, "Greens"),
bias = bias
)
@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()
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))
### 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:
@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)
@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")