data journalism final visualisation

Author

alysa juarez

loading libraries

library(tidyverse)
library(sf)
library(leaflet)

loading datasets

homeless_pop <- st_read(here::here("posts", "final-visualisation", "Homeless_Counts_2020/Homeless_Counts_2020.shp"))
Reading layer `Homeless_Counts_2020' from data source 
  `/home/runner/work/quarto-blog/quarto-blog/posts/final-visualisation/Homeless_Counts_2020/Homeless_Counts_2020.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 304 features and 12 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -118.9447 ymin: 32.79521 xmax: -117.6464 ymax: 34.8233
Geodetic CRS:  WGS 84
housing_assistance <- read_csv(here::here("posts", "final-visualisation", "Housing_Assistance_and_Information.csv"))

housing_assistance <- housing_assistance %>% 
  filter(!Name %in% c("Prototypes Star House Residential - Hollywood"))

mapping

laPalette <- colorNumeric(palette = "Blues",
                          domain=homeless_pop$Total_Unsh)
popup <- paste0("CSA: ", homeless_pop$CSA_Label,
                " || Total Unsheltered Homeless Population: ", homeless_pop$Total_Unsh)
leaflet(homeless_pop) %>%
  addProviderTiles("CartoDB.Positron") %>%
  addPolygons(stroke=FALSE, 
              smoothFactor = 0.2, 
              fillOpacity = .8, 
              popup=popup, 
              color= ~laPalette(homeless_pop$Total_Unsh)
              ) %>%
addCircleMarkers(data = housing_assistance, lng = ~longitude, lat = ~latitude,
                popup = ~Name, stroke = FALSE, radius = 5)