#Objective:
#1.To find the distance between two tracts of the Bexar county.
#2.Based on the results which one is accurate, NAD/83,South Central Texas projection or NAD/83/Texas Centric Albers Equal Area projection.
#3.To what extent the accuracy of projection is sensitive to this study.
#To connect census
library(tidycensus)
#special features
library(sf)
## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
sa_acs<-get_acs(geography = "tract",
state="TX",
county = c("Bexar"),
year = 2017,
variables=c( "DP05_0001E",
"DP03_0062E") ,
geometry = T, output = "wide")
## Getting data from the 2013-2017 5-year ACS
## Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
## Using the ACS Data Profile
#create a county FIPS code - 5 digit
sa_acs$county<-substr(sa_acs$GEOID, 1, 5)
#rename variables and filter missing cases
sa_acs2<-sa_acs%>%
mutate(totpop= DP05_0001E, pincome=DP03_0062E/1000) %>%
# st_transform(crs = 102740)%>%
na.omit()
st_crs(sa_acs2)
## Coordinate Reference System:
## EPSG: 4269
## proj4string: "+proj=longlat +datum=NAD83 +no_defs"
pincome_map<-sa_acs2 %>%
mutate(income=cut(pincome,breaks = quantile(pincome, na.rm=T, p=seq(0,1,length.out = 6)),include.lowest = T))
library(ggsn)
## Loading required package: ggplot2
## Loading required package: grid
p1<-ggplot(pincome_map, aes(fill = income, color = income)) +
geom_sf() +
ggtitle("Pecentage Median Household Income",
subtitle = "Bexar County Texas, 2017 - Quantile Breaks")+
scale_fill_brewer(palette = "Greens") +
scale_color_brewer(palette = "Greens")+
theme(axis.text.x = element_blank(), axis.text.y = element_blank())+
north(pincome_map)+
scalebar(pincome_map, location="bottomleft", dist=5, transform = T,dist_unit = "km", model="WGS84", st.size =2 )+
theme(legend.background = element_rect(size=0.5, linetype="solid", color = "black"))
p1
new_sa<-st_transform(sa_acs2, crs = 2278)
#Extract two tracts
twtr<-new_sa%>%
filter(GEOID %in% c(48029181820, 48029110600))
# get centroid coordinates for two tracts
tr_co<-st_centroid(twtr)
## Warning in st_centroid.sf(twtr): st_centroid assumes attributes are constant
## over geometries of x
#Measure feet apart
st_distance(tr_co)
## Units: [US_survey_foot]
## [,1] [,2]
## [1,] 0.00 64043.26
## [2,] 64043.26 0.00
new_sa<-st_transform(sa_acs2, crs = 3083)
#Extract two tracts
twtr<-new_sa%>%
filter(GEOID %in% c(48029181820, 48029110600))
# get centroid coordinates for two tracts
tr_co<-st_centroid(twtr)
## Warning in st_centroid.sf(twtr): st_centroid assumes attributes are constant
## over geometries of x
#Measure meter apart
st_distance(tr_co)
## Units: [m]
## [,1] [,2]
## [1,] 0.00 19536.81
## [2,] 19536.81 0.00
#The Texas south central proejction measures distance in feet. The Albers Equal Area measures distance in meter. However in Kilometer, both have 19.52km. Both are projected coordinated system thus they followed the linear measurement like feet, meter, or kilometer.
#Accurate system of projection must include same geographical coordinates. Projection flatens earth by transforming the longitudinal and latitudinal view of globe to a plane view. Thus it is important to have accurate system of projection where degree measurement is efficiently transform into linear measurement like feet, meter.In addition a quality map with less distortion of image. On that occasion only, Albers Equal Area projection could be a little behind than south-centric Texas projection. Becaue Albers Equal Area projection has 2D attributes on 3d map. Inspite of that both of them are approved by the Texas GIS committee as local map projection of Texas.
#For this case of median household income in Bexar county, it requires more accurate mapping and both of the projection gives accuracy to measure linear distance however, the tracts are less distorted to visualize in South centric Texas projection.