Here, I’ll be looking at some different projections Bexar county maps, and we will observe how changing the projection can change the output of a map.

First, we load the data from ACS. This is the same data as last time, our variable of focus is Median Household Income, even though that is not really what the homework is about:

library(tidycensus)
library(tidyverse)
## -- Attaching packages -------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.3     v dplyr   1.0.2
## v tidyr   1.1.1     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts ----------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(sf)
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(ggplot2)
acs_variables <- load_variables(2017 , "acs5/profile", cache = TRUE) 


#getting median income data
 
median_hsincome<-acs_variables %>% filter(name=="DP03_0062")
#narrowing focus to Bexar county

sa_acs<-get_acs(geography = "tract",
                state="TX",
                county = c("Bexar"),
                year = 2017,
                variables=c( "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
#rename variables and filter missing cases

sa_acs2<-sa_acs %>%
  mutate(median_hs_income= DP03_0062E) %>%
  na.omit()

NAD83 - Texas South Central vs. Texas Centric Albers Equal Area

Here, I will compare the NAD83 Texas South Central projection versus the Texas Centric Albers Equal Area projection. I will do this by comparing the distance between two coordinates in both projections.

library(tmap)
library(tmaptools)

tm_shape(sa_acs2)+
  tm_polygons("median_hs_income", title="Bexar County Household Income", palette="Blues", style="quantile", n=5 ,legend.hist=T)+
  tm_format("World", title="Median Household Income - Quantile Breaks", legend.outside=T)+
  tm_scale_bar()+
  tm_compass()

Texas South Central Projection

Here is the distance between two coordinates (48029181820, 48029110600) in Texas South Central Projection (CRS=2278)

#spatialreference.org

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 64043
## [2,] 64043     0

We see that the difference is 64,043.26 feet.

Texas Centric Albers Equal Area

Here is the distance between the same two coordinates, but in the Texas Centric Albers Equal Area projection (CRS=3803):

#spatialreference.org

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 feet apart
st_distance(tr_co)
## Units: [m]
##       [,1]  [,2]
## [1,]     0 19537
## [2,] 19537     0

The first projection uses feet, while the second uses meters. The second measurement of distance is 19,536 meters. For ease of use, we can turn meters into feet through a simple calculation:

meters*3.28084 = feet

Which gives us:

Texas South Central Projection: 64043.26 feet

Texas Centric Albers Equal Area: 64097.15 feet

Which is a difference of 53.89 feet

Conclusion

In conclusion, we see that the difference between to identical points in these two projections can be off almost 54 feet. While this may seem like a small amount, it suggests that the choice of projection in GIS research does matter!