Skip to content

Instantly share code, notes, and snippets.

View elipousson's full-sized avatar

Eli Pousson elipousson

View GitHub Profile
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
@elipousson
elipousson / baltimore-area_arcgis-rest-server-connections_qgis.xml
Created August 24, 2022 16:45
Connections export file to load into QGIS using the ArcGIS REST Services feature of the Browser panel. All servers are public and do not authentication to access. This connection list is a subset of the Maryland ArcGIS REST API Services index: https://docs.google.com/spreadsheets/d/1c829bZdNqvbpoizulBU_XE5jVeNNck2kHkS-smpQ52s/edit?usp=sharing
<!DOCTYPE connections>
<qgsARCGISFEATURESERVERConnections version="1.0">
<arcgisfeatureserver authcfg="" referer="" username="" url="https://gis.aacounty.org/arcgis/rest/services" name="Anne Arundel County GIS" password=""/>
<arcgisfeatureserver authcfg="" referer="" username="" url="https://services1.arcgis.com/mVFRs7NF4iFitgbY/arcgis/rest/services" name="BNIA-JFI Vital Signs Open Data Portal" password=""/>
<arcgisfeatureserver authcfg="" referer="" username="" url="https://services1.arcgis.com/UWYHeuuJISiGmgXx/ArcGIS/rest/services" name="Baltimore City ArcGIS Online Assorted" password=""/>
<arcgisfeatureserver authcfg="" referer="" username="" url="https://dotgis.baltimorecity.gov/arcgis/rest/services" name="Baltimore City DOT GIS" password=""/>
<arcgisfeatureserver authcfg="" referer="" username="" url="https://dpwgis.baltimorecity.gov/ags102/rest/services" name="Baltimore City DPW GIS" password=""/>
<arcgisfeatureserver authcfg="" referer="" username="" url="https://services1.arcgi
@elipousson
elipousson / 2022-07-20_noi-zip.R
Last active July 21, 2022 02:18
A R script to convert Maryland open data on notice of intent to foreclose by zipcode from a wide to a long format and create basic visualizations. Data: https://opendata.maryland.gov/Housing/Maryland-Notices-of-Intent-to-Foreclose-by-Zip-Cod/ftsr-vapt
library(dplyr)
library(ggplot2)
# pak::pkg_install("elipousson/mapmaryland")
plot_theme <- list(
hrbrthemes::theme_ipsum_pub(base_size = 15),
cols4all::scale_color_discrete_c4a_cat(palette = "tol.medium"),
cols4all::scale_fill_discrete_c4a_cat(palette = "tol.medium")
)
---
title: "mapbaltimore, getdata, and maplayer"
output: html_document
date: '2022-07-15'
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"