Skip to content

Instantly share code, notes, and snippets.

View elipousson's full-sized avatar

Eli Pousson elipousson

View GitHub Profile
@elipousson
elipousson / baltimore-bike-facilities_schema-update.R
Last active September 9, 2023 19:36
A R script for updating the Baltimore bike facilities data to use the new schema from the Baltimore Metropolitan Council and add other related attributes as variables.
# title: R script for validating Baltimore city bike facility data, updating the
# schema to match new BMC standard, and adding new attributes for responsible
# agency and other characteristics
#
# author: Eli Pousson
# date: 2023-09-07
# last-modified: 2023-09-09
# Set up ----
@elipousson
elipousson / read_excalidraw.R
Created September 5, 2023 02:00
A R function to read an Excalidraw Markdown file created with Obsidian to a list
#' Read an Excalidraw Markdown file created using the Obsidian Excalidraw
#' plugin.
#'
#' Plugin: https://github.com/zsviczian/obsidian-excalidraw-plugin
#'
#' This function uses the experimental yyjsonr package
#' <https://github.com/coolbutuseless/yyjsonr>. jsonlite would also work here.
#'
#' @param file A Markdown file created with the Obsidian Excalidraw plugin.
#' @param ... Additional parameters passed to [readr::read_lines()]
table <- tidycensus::get_decennial(
geography = "block",
state = "MD",
county = "Baltimore city",
year = 2020,
table = "H1"
)
label_census <- function(data,
year = 2020,
library(tidyverse)
# requires bcpss, getdata, mapmaryland, ggplot2 and dplyr
params <-
list(
program_name = c(
"John Ruhrah Elementary/Middle",
"John Ruhrah Elementary"
),
program_number = 228
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))
nc_random_pts <- sf::st_sample(nc, size = 1000)
nc_random_pts <- sf::st_join(sf::st_as_sf(nc_random_pts), nc)
bind_pt_coords <- function(x, ..., .drop = TRUE) {
if (sf::st_geometry_type(x, FALSE) != "POINT") {
coords <- suppressWarnings(sf::st_coordinates(sf::st_centroid(x)))
} else {
#' Is x an GeoPackage filename or path?
#'
#' @param x File name or path name
#' @noRd
is_gpkg <- function(x) {
grepl("\\.gpkg$", x)
}
#' Check if x is a GeoPackage file
#'
library(getdata)
library(ggplot2)
library(mapmaryland)
library(maplayer)
library(dplyr)
dead_zones <-
get_esri_data(
url = "https://geodata.md.gov/imap/rest/services/Environment/MD_ChesapeakeBayDeadZones/FeatureServer/0",
crs = 3857
@elipousson
elipousson / ggplot2_helpers.aia
Created November 1, 2022 17:43
Actions for cleaning up ggplot2 plots in Adobe Illustrator
/version 3
/name [ 15
6767706c6f74322068656c70657273
]
/isOpen 1
/actionCount 2
/action-1 {
/name [ 13
52656c65617365204d61736b73
]
# read_sf_felt(
# "https://felt.com/embed/map/Example-Greatest-Bowling-Alleys-in-the-US-W9A04huJxTSCxfESYhkY9AOA"
# )
read_sf_felt <- function(url) {
req <-
httr2::request(
url
)
@elipousson
elipousson / 2022-09-13_photo-tagging-streets-intersections.R
Created September 13, 2022 16:30
An R script to update the exif metadata for titles and descriptions for a photographs (in a single folder) of streets and intersections in Baltimore, MD. Related thread: https://twitter.com/elipousson/status/1569722352954490880
# pak::pkg_install("elipousson/mapbaltimore")
# pak::pkg_install("elipousson/sfext")
# pak::pkg_install("elipousson/getdata")
library(dplyr)
library(purrr)
library(sfext)
library(mapbaltimore)
# path = # path to folder with photos