Skip to content

Instantly share code, notes, and snippets.

View walkerke's full-sized avatar

Kyle Walker walkerke

View GitHub Profile
# Day 25: Hexagons - US Wind Energy Infrastructure
# Multi-resolution H3 hexagonal aggregation of 72,000+ wind turbines
# Aggregating total installed capacity (MW) per hexagon
# Points fade in at high zoom for individual turbine exploration
library(mapgl)
library(h3o)
library(sf)
library(dplyr)
library(readr)
library(mapgl) # Get the new features: pak::pak("walkerke/mapgl")
library(tidycensus)
library(sf)
library(tidyverse)
sf_use_s2(FALSE)
tx_bgs <- get_acs(
geography = "block group",
variables = "B01001_001",
state = "TX",
# DuckDB Vector Tiles with mapgl Example
# This script demonstrates how to serve vector tiles from DuckDB using ST_AsMVT()
# and display them in a mapgl map using httpuv
library(mapgl)
library(duckdb) # Requires the latest DuckDB version (>= 1.4.0)
library(httpuv)
library(sf)
library(duckspatial)
library(tigris)
# remotes::install_github("walkerke/mapgl")
library(mapgl)
# CYBERPUNK 2125 - Ultra-striking neon palette
# Deep blacks + electric neons for that Blade Runner / Akira vibe
cyberpunk_2125 <- c(
"#000000", # Pure black (shadows)
"#0a0e27", # Deep space blue (dark areas)
"#1a1a2e", # Dark navy (buildings)
"#16213e", # Midnight blue
# remotes::install_github("walkerke/mapgl")
library(mapgl)
library(sf)
library(dplyr)
# Set seed for reproducibility
set.seed(42)
# Define the bounding box for Dallas (approximately)
dallas_bbox <- st_bbox(c(
library(tidycensus)
library(tigris)
library(tidyverse)
options(tigris_use_cache = TRUE)
# Grab the data
us_income <- get_acs(
geography = "puma",
variables = "B19013_001",
year = 2023,
library(mapgl)
pmtiles <- "https://r2-public.protomaps.com/protomaps-sample-datasets/cb_2018_us_zcta510_500k.pmtiles"
maplibre(center = c(-97, 35), zoom= 3) |>
set_projection("globe") |>
add_vector_source("pmtiles_source",
url = paste0("pmtiles://", pmtiles)
) |>
add_fill_layer(
library(tidyverse)
library(tidycensus)
# Get the data
pyramid_data <- get_estimates(
geography = "state",
product = "characteristics",
breakdown = c("AGEGROUP", "SEX"),
breakdown_labels = TRUE,
vintage = 2024,
# Day 26: Transport - US Electric Power Transmission Lines
# Visualizing America's invisible highway: 700,000+ miles of power lines
# Dynamic line widths by voltage class, glowing effect for the energy flow
library(mapgl)
library(sf)
library(dplyr)
# Load transmission lines from HIFLD (Homeland Infrastructure Foundation-Level Data)
# This is a large dataset - we'll use direct URL for the GeoJSON
# Day 27: Boundaries - World Time Zones
# Shows current time in each timezone
library(mapgl)
library(sf)
library(dplyr)
library(lubridate)
# Get user's current timezone and time
user_tz <- Sys.timezone()