library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(tmap)
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
library(tidycensus)
library(tigris)
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
#Q1
bexar_ct <-tracts(state = "TX", county = "Bexar" , cb=T)
## Retrieving data for the year 2022
## | | | 0% | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 7% | |===== | 8% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========= | 14% | |========== | 14% | |========== | 15% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============== | 19% | |============== | 20% | |=============== | 22% | |================= | 24% | |================= | 25% | |=================== | 27% | |==================== | 28% | |====================== | 31% | |======================= | 33% | |======================== | 34% | |========================= | 36% | |============================== | 42% | |=============================== | 45% | |====================================== | 54% | |======================================= | 56% | |========================================= | 58% | |========================================== | 60% | |============================================= | 64% | |================================================ | 68% | |=================================================== | 74% | |======================================================= | 78% | |=========================================================== | 84% | |============================================================= | 87% | |============================================================= | 88% | |=============================================================== | 89% | |=================================================================== | 96% | |======================================================================| 100%
bond_program_line <- st_read("C:/Users/dejmo/OneDrive/Documents/URP Cert/URP 5363- Planning Methods I/Assignment 4/BondProjectLines2017/BondProjectLines2017.shp")
## Reading layer `BondProjectLines2017' from data source
## `C:\Users\dejmo\OneDrive\Documents\URP Cert\URP 5363- Planning Methods I\Assignment 4\BondProjectLines2017\BondProjectLines2017.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 69 features and 24 fields
## Geometry type: MULTILINESTRING
## Dimension: XY
## Bounding box: xmin: 2078269 ymin: 13665110 xmax: 2168346 ymax: 13783530
## Projected CRS: NAD83 / Texas South Central (ftUS)
tm_shape(bexar_ct)+
tm_borders()+
tm_shape(bond_program_line)+
tm_lines(col='green')
#Q2
libraries <- st_read("C:/Users/dejmo/OneDrive/Documents/URP Cert/URP 5363- Planning Methods I/Assignment 4/Libraries/Libraries.shp")
## Reading layer `Libraries' from data source
## `C:\Users\dejmo\OneDrive\Documents\URP Cert\URP 5363- Planning Methods I\Assignment 4\Libraries\Libraries.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 30 features and 9 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 2075828 ymin: 13669570 xmax: 2170361 ymax: 13779280
## Projected CRS: NAD83 / Texas South Central (ftUS)
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(bexar_ct)+
tm_borders()+
tm_shape(libraries)+
tm_dots(col='red')
#Q3
var <- c(poptotal2='B17017_001E',
poverty='B17017_002E')
st <-"TX"
ct <-"Travis"
cbg <- get_acs(geography = "block group", variables = var, count=ct,
state = st,output="wide", year = 2021, geometry = TRUE)
## Getting data from the 2017-2021 5-year ACS
## Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
## | | | 0% | |==== | 5% | |===== | 7% | |====== | 8% | |======== | 11% | |========== | 14% | |============ | 17% | |=============== | 21% | |================= | 25% | |================== | 25% | |================== | 26% | |=================== | 26% | |=================== | 27% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |======================= | 33% | |========================= | 36% | |========================== | 37% | |========================== | 38% | |=========================== | 38% | |============================== | 42% | |================================ | 46% | |==================================== | 51% | |==================================== | 52% | |===================================== | 52% | |===================================== | 53% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 59% | |============================================= | 64% | |============================================== | 66% | |================================================ | 69% | |================================================== | 72% | |====================================================== | 77% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 82% | |============================================================= | 86% | |============================================================== | 89% | |================================================================ | 92% | |================================================================== | 95% | |==================================================================== | 97% | |======================================================================| 100%
cbg$poverty_rate <- cbg$poverty/cbg$poptotal2
tm_shape(cbg)+
tm_polygons(col="poverty_rate",
palette="RdYlGn")
#Q4
bexar_ct <-st_transform(bexar_ct, crs = 4326)
libraries<-st_transform(libraries,crs = 4326)
library_ct <- st_intersection(libraries, bexar_ct)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.