Lab 7.2

Whataburger and Population Overlay for Texas - Peer Feedback Revisions

Author

Julie Milligan

library(ggplot2)
library(ggthemes)
library(socviz)
library(maps)
library(mapproj)
library(viridis)

GET TEXAS POPULATION DATA BY COUNTY DIRECTLY FROM THE US CENSUS VIA API

CREATE A CHOLOPLETH USING LEAFLET FOR TEXAS COUNTIES

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

library(sf)
tx_pop %>% 
  st_transform(crs = "+proj=longlat +datum=WGS84") %>% 
  leaflet(width = "100%", height = 500) %>% 
  addProviderTiles(provider = "Esri.WorldPhysical") %>% 
  addPolygons(popup = ~NAME,
              stroke = FALSE,
              smoothFactor = 0,
              fillOpacity = 0.8,
              color = ~ MapPalette(estimate)) %>% 
  addLegend("bottomright", 
            pal = MapPalette,
            values = ~ estimate,
            title = "Population Percentiles",
            opacity = 1) 
  • More heavily populated counties appear to be on the eastern side of the state. Not much to be found in west Texas.
  • Counties near bigger cities such as Dallas, Fort Worth, Austin, San Antonio, and Houston have the highest population percentiles.
  • The interactive popups indicate whichever county the viewer clicks on.

PLOT WHATABURGER LOCATIONS IN TEXAS

# load all USA Whataburger locations
whataburgerUS <- read.csv("whataburger_2018_11_06.csv")
save(whataburgerUS, file = "whataburgerUS.RData")

load("whataburgerUS.RData")
head(whataburgerUS)
                   name
1  Old Fannin & Flowood
2 New Boston & Robinson
3         Hwy 62 & Sang
4        Hwy 71 & Joyce
5     I49 & Elm Springs
6     I55 & County Line
                                                                                     url
1                  https://locations.whataburger.com//ms/flowood/1724-old-fannin-rd.html
2                https://locations.whataburger.com//tx/texarkana/2727-new-boston-rd.html
3 https://locations.whataburger.com//ar/fayetteville/1956-w-martin-luther-king-blvd.html
4              https://locations.whataburger.com/ar/fayetteville/4030-n-college-ave.html
5              https://locations.whataburger.com//ar/springdale/4172-elm-springs-rd.html
6              https://locations.whataburger.com//ms/ridgeland/800-e-county-line-rd.html
                  street_address         city state zip_code country
1             1724 Old Fannin Rd      Flowood    MS    39232      US
2             2727 New Boston Rd    Texarkana    TX    75501      US
3 1956 W Martin Luther King Blvd Fayetteville    AR    72701      US
4             4030 N College Ave Fayetteville    AR    72703      US
5            4172 Elm Springs Rd   Springdale    AR    72762      US
6           800 E County Line Rd    Ridgeland    MS    39157      US
  phone_number_1 phone_number_2 fax_1 fax_2 email_1 email_2 website
1 (601) 992-3326             NA    NA    NA      NA      NA      NA
2 (903) 832-2727             NA    NA    NA      NA      NA      NA
3 (479) 443-2217             NA    NA    NA      NA      NA      NA
4 (479) 442-2226             NA    NA    NA      NA      NA      NA
5 (479) 750-2754             NA    NA    NA      NA      NA      NA
6 (601) 956-6466             NA    NA    NA      NA      NA      NA
                                                                                                                                                  open_hours
1                                                                  Mon : 24 hr, Tue : 24 hr, Wed : 24 hr, Thu : 24 hr, Fri : 24 hr, Sat : 24 hr, Sun : 24 hr
2 Mon : 7:00 AM - 11:00 PM, Tue : 7:00 AM - 11:00 PM, Wed : 7:00 AM - 11:00 PM, Thu : 7:00 AM - 11:00 PM, Fri : 24 hr, Sat : 24 hr, Sun : 7:00 AM - 11:00 PM
3                                                                  Mon : 24 hr, Tue : 24 hr, Wed : 24 hr, Thu : 24 hr, Fri : 24 hr, Sat : 24 hr, Sun : 24 hr
4                                                                  Mon : 24 hr, Tue : 24 hr, Wed : 24 hr, Thu : 24 hr, Fri : 24 hr, Sat : 24 hr, Sun : 24 hr
5                                                                  Mon : 24 hr, Tue : 24 hr, Wed : 24 hr, Thu : 24 hr, Fri : 24 hr, Sat : 24 hr, Sun : 24 hr
6                                                                  Mon : 24 hr, Tue : 24 hr, Wed : 24 hr, Thu : 24 hr, Fri : 24 hr, Sat : 24 hr, Sun : 24 hr
  latitude longitude facebook twitter instagram pinterest youtube
1 32.34204 -90.06534       NA      NA        NA        NA      NA
2 33.43541 -94.07800       NA      NA        NA        NA      NA
3 36.05668 -94.18793       NA      NA        NA        NA      NA
4 36.12441 -94.14398       NA      NA        NA        NA      NA
5 36.19367 -94.17619       NA      NA        NA        NA      NA
6 32.40014 -90.14359       NA      NA        NA        NA      NA
# filter for just TX
sbar <- whataburgerUS %>% filter(state=="TX")

# plot leaflet
sbar %>% leaflet(width = "100%") %>% 
             addTiles() %>% 
             setView(-98.0, 31.0, zoom = 5) %>% 
             addMarkers(lat = ~latitude, 
                                 lng = ~longitude,
                                 popup = sbar$name)
  • Whataburger locations in the east appear to be more prevalent, especially near the big cities that were noted above.
  • These locations can be found off of major highways all throughout the state.
  • While there aren’t as many locations out west, the ones that seem to standout are located in cities with universities/colleges.

COMBINE CHOROPLETH AND LOCATIONS – Overlay Whataburger Locations Onto Choropleth

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

whataburger_icon <- makeIcon(
  iconUrl = "whatalogo.PNG",
  iconWidth = 15,  
  iconHeight = 15)

tx_pop %>% 
  st_transform(crs = "+proj=longlat +datum=WGS84") %>% 
  leaflet(width = "100%", height = 500) %>% 
  addProviderTiles(provider = "Esri.WorldPhysical") %>% 
  addPolygons(popup = ~NAME,
              stroke = FALSE,
              smoothFactor = 0,
              fillOpacity = 0.8,
              color = ~ MapPalette(estimate)) %>%
  addLegend("bottomright", 
            pal = MapPalette,
            values = ~ estimate,
            title = "Population Percentiles",
            opacity = 1) %>% 
  addMarkers(data = sbar, 
             lat = ~latitude,
             lng = ~longitude,
             icon = whataburger_icon,
             popup = ~name)
  • With similar insights from above, we can tell that east Texas contains several Whataburger locations. These higher location frequencies also line up with the more populated counties in the state.
  • I liked the idea of incorporating the Whataburger logo onto the map so that viewers may quickly know what they might be looking at. However, since there are so many locations in east Texas, it can look somewhat chaotic at first.
  • I chose to use the blue color palette for the counties and their different population percentiles because blue is opposite of orange on the color wheel and I figured that would be the best way to make the logos pop to the viewer.
  • Interactive popups are available to indicate both the county selected and where a specific Whataburger is located.

PEER FEEDBACK

  • Based on the feedback I received from my peers, I do not need to make any changes to my maps.
    I got several compliments on my work!

END