This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(mapgl) | |
| library(tidycensus) | |
| tarrant_age <- get_acs( | |
| geography = "tract", | |
| variables = "B01002_001", | |
| state = "TX", | |
| county = "Tarrant", | |
| geometry = TRUE | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(mapgl) | |
| library(tigris) | |
| library(dplyr) | |
| library(sf) | |
| texas <- states(cb = TRUE) |> | |
| filter(NAME == "Texas") | |
| points <- st_sample(texas, 5000) |> | |
| st_sfc() |> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tigris) | |
| library(tidyverse) | |
| library(sf) | |
| library(mapgl) | |
| library(bslib) | |
| library(shiny) | |
| options(tigris_use_cache = TRUE) | |
| dfw_cbsa <- core_based_statistical_areas(cb = TRUE) |> filter(GEOID == "19100") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(tidycensus) | |
| # Get the data | |
| pyramid_data <- get_estimates( | |
| geography = "state", | |
| product = "characteristics", | |
| breakdown = c("AGEGROUP", "SEX"), | |
| breakdown_labels = TRUE, | |
| vintage = 2024, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(mapgl) # pak::pak("walkerke/mapgl") | |
| library(tidycensus) | |
| library(dplyr) | |
| library(viridisLite) | |
| # Get viridis colors | |
| viridis_colors <- viridis(5) | |
| # Get median household income by county in Texas | |
| tx_income <- get_acs( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidycensus) | |
| library(mapgl) | |
| # load_variables(2023, "acs1/profile") |> View() | |
| births_per_1000 <- get_acs( | |
| geography = "puma", | |
| year = 2023, | |
| variables = "DP02_0040", | |
| survey = "acs5", |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( |
NewerOlder