#30DayMapChallenge: Restaurant heat map of Madison

Madison (WI) map

Challenge 15: Food/drink

Harald Kliems https://haraldkliems.netlify.app/
2022-11-16
Show code

Another quick #30DayMapChallenge post. The prompt for day 15: Food/drink. Public Health Madison & Dane County have a dataset on health inspections which includes all licensed restaurants in the county. The data are not geocoded, and so I use the mapboxapi package to geocode the locations:

Show code
establishments <- read_csv("data/Licensed_Establishment.csv")

# geocode and save geocoded data
# est_sf <- establishments %>% 
#   rowwise() %>% 
#   mutate(geometry = mb_geocode(AddressFull, output = "sf"),
#          geometry = geometry$geometry)
# 
# est_sf <- st_sf(est_sf)
# 
# write_rds(est_sf, file = "data/licensed_establishment_geocoded.RDS")
est_sf <- readRDS("data/licensed_establishment_geocoded.RDS")

The dataset includes “all operational licensed establishments receiving routine inspections,” that is, not just restaurants. A quick tmap (we have to filter out a food cart that’s located in Milwaukee):

Show code
tmap_mode("plot")
est_sf %>% 
  filter(AddrCity != "MILWAUKEE") %>% 
  tm_shape() +
  tm_dots("EstablishmentType") +
  tm_layout(legend.outside = T)

Now we filter to only establishments that are of the type “Primarily Restaurant” and create a heat map. Heat maps look cool, but I admittedly don’t fully understand how leaflet.extras generates them under the hood – certainly the map looks very different depending on the zoom level.

Show code
leaflet(est_sf %>% filter(EstablishmentType == "Primarily Restaurant")) %>% 
  addTiles() %>% 
  addHeatmap(radius = 6)

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-SA 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Kliems (2022, Nov. 16). Harald Kliems: #30DayMapChallenge: Restaurant heat map of Madison. Retrieved from https://haraldkliems.netlify.app/posts/2022-11-16-food-establishment-data-from-madison/

BibTeX citation

@misc{kliems2022#30daymapchallenge:,
  author = {Kliems, Harald},
  title = {Harald Kliems: #30DayMapChallenge: Restaurant heat map of Madison},
  url = {https://haraldkliems.netlify.app/posts/2022-11-16-food-establishment-data-from-madison/},
  year = {2022}
}