Skip to content

Instantly share code, notes, and snippets.

View walkerke's full-sized avatar

Kyle Walker walkerke

View GitHub Profile
@walkerke
walkerke / make_GeodesicBuffer.R
Last active December 13, 2019 15:51 — forked from valentinitnelav/make_GeodesicBuffer.R
Geodesic buffer for point data
make_GeodesicBuffer <- function(XY.dg, dg.step=5, dst.m, crs){
#######################################################################################################
## Function to make a circle-buffer around given points (long-lat coordinates)
## Is different from rgeos::gBuffer() by the fact that it allows the user to create
## a geodesic buffer with a width expressed in metric units.
## Otherwise the user needs to project and apply an Euclidian buffer with rgeos::gBuffer(),
## which will introduce distortions that vary greatly with latitude and the radius of the circle buffer.
## See also my question addressed here:
## https://gis.stackexchange.com/questions/250389/euclidean-and-geodesic-buffering-in-r
##
library(tigris)
library(tidyverse)
options(tigris_use_cache = TRUE)
st <- c(state.abb, "DC")
alltracts <- map(st, function(x) {
tracts(state = x, cb = TRUE, class = "sf")
}) %>%
rbind_tigris()
library(cancensus)
library(tidyverse)
library(sf)
library(tmap)
library(tmaptools)
options(cancensus.api_key = "your key goes here")
montreal <- get_census(dataset = "CA16", regions = list(CMA = "24462"),
vectors = c("v_CA16_1364", "v_CA16_1367"), level = "CT",
geo_format = "sf", labels = "short")
library(tidycensus)
library(tidyverse)
library(extrafont)
library(plotly)
place00 <- get_decennial(geography = "place", state = "TX",
variables = "P001001", year = 2000) %>%
mutate(NAME = str_replace(NAME, " city.*", "")) %>%
select(NAME, pop00 = value)
library(tidycensus)
library(tmap)
library(tmaptools)
library(sf)
library(tigris)
library(magick)
library(tidyverse)
options(tigris_use_cache = TRUE)
ctys <- c("Dallas", "Tarrant", "Collin County", "Denton",
library(tidycensus)
mn <- get_acs(geography = "school district (unified)",
state = "MN",
variables = c(hhincome = "B19013_001"))
mn
# A tibble: 326 x 5
GEOID NAME variable estimate moe
library(tidycensus)
library(tidyverse)
library(extrafont)
city16 <- get_acs(geography = "place",
variables = "B01003_001",
survey = "acs1") %>%
filter(estimate > 500000) %>%
rename(estimate16 = estimate)
library(tidycensus)
library(tidyverse)
library(extrafont)
info <- get_acs(geography = "metropolitan statistical area/micropolitan statistical area",
variables = "DP03_0039P",
summary_var = "B01003_001",
survey = "acs1") %>%
filter(summary_est > 1500000) %>%
mutate(NAME = str_replace(NAME, "-.*", "")) %>%
library(tidycensus)
library(plotly)
library(ggplot2) # devtools::install_github("tidyverse/ggplot2")
library(crosstalk)
# Set your Census API key with `census_api_key()` if not already installed
tx <- get_acs(geography = "county",
variables = c(pctcollege = "DP02_0067P",
hhincome = "DP03_0062"),
state = "TX",
library(tidycensus)
library(leaflet)
library(sf)
library(viridis)
options(tigris_use_cache = TRUE)
il1 <- get_acs(geography = "county",
variables = c(hhincome = "B19013_001"),
state = "IL",
geometry = TRUE) %>%