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
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 | |
## |
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) | |
options(tigris_use_cache = TRUE) | |
st <- c(state.abb, "DC") | |
alltracts <- map(st, function(x) { | |
tracts(state = x, cb = TRUE, class = "sf") | |
}) %>% | |
rbind_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(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") |
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(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) |
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(tmap) | |
library(tmaptools) | |
library(sf) | |
library(tigris) | |
library(magick) | |
library(tidyverse) | |
options(tigris_use_cache = TRUE) | |
ctys <- c("Dallas", "Tarrant", "Collin County", "Denton", |
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) | |
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 |
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(tidyverse) | |
library(extrafont) | |
city16 <- get_acs(geography = "place", | |
variables = "B01003_001", | |
survey = "acs1") %>% | |
filter(estimate > 500000) %>% | |
rename(estimate16 = estimate) |
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(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, "-.*", "")) %>% |
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(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", |
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(leaflet) | |
library(sf) | |
library(viridis) | |
options(tigris_use_cache = TRUE) | |
il1 <- get_acs(geography = "county", | |
variables = c(hhincome = "B19013_001"), | |
state = "IL", | |
geometry = TRUE) %>% |