Lab 7.1

Whataburger and Texas Population Overlay

Author

Lincoln Morphis

library(tidyverse)
library(ggplot2)
library(ggthemes)
library(socviz)
library(maps)
library(mapproj)
library(questionr)
library(viridis)
library(leaflet)
library(tidycensus)
options(scipen=999) 

TEXAS POPULATION DATA

TEXAS POPULATION DATA CHOROPLETH

MapPalette <- colorQuantile(palette = "viridis", domain = tx_pop$estimate, n = 20)

tx_pop %>% 
  st_transform(crs = "+proj=longlat +datum=WGS84") %>% 
  leaflet(width = "100%", height = 500) %>% 
addProviderTiles(provider = "OpenStreetMap") %>% 
  addPolygons(popup = ~NAME,
              stroke = FALSE,
              smoothFactor = 0,
              fillOpacity = 0.6,
              color = ~ MapPalette(estimate)) %>% 
  addLegend("bottomright", 
            pal = MapPalette,
            values = ~ estimate,
            title = "Population Percentiles",
            opacity = 1) 

INSIGHTS

As clearly indicated by the choropleth, the cities that hold highest percentage of the population of Texas are Dallas, Houston, and Austin.
A significantly strong majority of the population lives on the eastern side of Texas. But one city in the west, Ciudad Juarez, holds a high population.

whataburgerUS <- read.csv("https://query.data.world/s/2at5gztiuyuvisdsoq5o44tjaq7hlr?dws=00000", header=TRUE, stringsAsFactors=FALSE)

WHATABURGUR RESTAURAUNT LOCATIONS OVERLAYED ON CHOROPLETH

MapPalette <- colorQuantile(palette = "viridis", domain = tx_pop$estimate, n = 20)

tx_pop %>% 
  st_transform(crs = "+proj=longlat +datum=WGS84") %>% 
  leaflet(width = "100%", height = 500) %>% 
addProviderTiles(provider = "OpenStreetMap") %>%
  addPolygons(popup = ~NAME,
              stroke = FALSE,
              smoothFactor = 0,
              fillOpacity = 0.5,
              color = ~ MapPalette(estimate)) %>% 
  addLegend("bottomright", 
            pal = MapPalette,
            values = ~ estimate,
            title = "Population Percentiles",
            opacity = 5) %>% 
  addCircleMarkers(data = whataburgerUS, 
                   lat = whataburgerUS$latitude,
                   lng = whataburgerUS$longitude,
                   popup = whataburgerUS$name,
                   weight = 3,
                   radius=3,
                   color = "orangered", 
                   opacity = 1)

INSIGHTS

As expected, most of the whataburger locations reside in Dallas, Houston, and San Antonio.
The more separated from the East you get, the amount of locations drops down significantly.

END