library(tidyverse)
library(sf)
library(leaflet)
loading libraries
loading datasets
<- st_read(here::here("posts", "final-visualisation", "Homeless_Counts_2020/Homeless_Counts_2020.shp")) homeless_pop
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
<- read_csv(here::here("posts", "final-visualisation", "Housing_Assistance_and_Information.csv"))
housing_assistance
<- housing_assistance %>%
housing_assistance filter(!Name %in% c("Prototypes Star House Residential - Hollywood"))
mapping
<- colorNumeric(palette = "Blues",
laPalette domain=homeless_pop$Total_Unsh)
<- paste0("CSA: ", homeless_pop$CSA_Label,
popup " || 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)