From ae3a65438eb660e2676c4e5097684336e4ee8efa Mon Sep 17 00:00:00 2001 From: Ben Varick Date: Mon, 8 Apr 2024 10:09:18 -0500 Subject: [PATCH] removed county pop circles/nadded county lines when zoomed in/nadded school icons --- .../wisconsin_pedestrian_crash_map.html | 6 +-- other/school_FILL0_wght400_GRAD0_opsz24.png | Bin 0 -> 1042 bytes scripts/dynamic_crash_map.R | 37 ++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 other/school_FILL0_wght400_GRAD0_opsz24.png diff --git a/figures/dynamic_crash_maps/wisconsin_pedestrian_crash_map.html b/figures/dynamic_crash_maps/wisconsin_pedestrian_crash_map.html index 7e00f20..aec1b34 100644 --- a/figures/dynamic_crash_maps/wisconsin_pedestrian_crash_map.html +++ b/figures/dynamic_crash_maps/wisconsin_pedestrian_crash_map.html @@ -5254,9 +5254,9 @@ function asArray(value) {
-
+
- - + + diff --git a/other/school_FILL0_wght400_GRAD0_opsz24.png b/other/school_FILL0_wght400_GRAD0_opsz24.png new file mode 100644 index 0000000000000000000000000000000000000000..950373e13852a9008a64a1b30b0c5ffd1882ba34 GIT binary patch literal 1042 zcmV+t1nv8YP)PzXf1c)}^i4P#? z-N25T1p(FqcN_pge*kQ#84zFr&;g93fT;Q?a204CHxQr^I13Cp0__5}n|C>$8#1lN zF#`dn0!M()j==ue*bxaJ=wE@8!1U5UiVDOx5TDWvL?IvvGSQIjli4W-W~M>^aOft^ zaB-c*Wug(=tc!B&wfQy(za9O=X1FNv1;9nTtP&-D8(5PSAf(UbHYlzvcY}xw7ZjUi z)BV#SRspsY1rP$X9=Px5|Ci0+oKO&8FEHQ`_y+6(q$~(uEMk3qbHpz zI~sQ--F!Jg+JMI~%S?d}k$VJ~mvHlKECHZ}bjO@%5TEF3;Fd#V6u1s7D*#}bX}OZi zEnt6YkQCEAY%@4F13)8Qa&aAVo>iAKusJh`3Dnt$xu$s#I04K^pf|&w9gNYu4%GSD zMS>){>ZSQRr~q(uM{WMYS3?qKIHY| zm3k(Zt@Dp=hNE|bb>g}f_gS$1ldIs>#d;j=2Jy~mu_x%)`mWyrFdl=*X_>bw}F+p%Ly526#5yj;#`0xosUTx%|IK^$36NT|36NT|KNdP|mAzu6SpWb4 M07*qoM6N<$f^NsuN&o-= literal 0 HcmV?d00001 diff --git a/scripts/dynamic_crash_map.R b/scripts/dynamic_crash_map.R index 08c55c3..90940e6 100644 --- a/scripts/dynamic_crash_map.R +++ b/scripts/dynamic_crash_map.R @@ -96,7 +96,11 @@ WI_schools <- WI_schools %>% LAT > 0) %>% select("SCHOOL", "DISTRICT", "SCHOOLTYPE", "LAT", "LON") -school_symbol <- image_read_svg(path = "other/school_FILL0_wght400_GRAD0_opsz24.svg") +school_symbol <- makeIcon(iconUrl = "other/school_FILL0_wght400_GRAD0_opsz24.png", + iconWidth = 24, + iconHeight = 24, + iconAnchorX = 12, + iconAnchorY = 12) focus_columns <- c("PedestrianInjurySeverity", "CrashDate", "CrashTime", "County", "Street", "CrossStreet", "PedestrianAge", "Year", "vulnerable_role") @@ -171,9 +175,15 @@ wisconsin_crash_map <- # addControl(title, position = "topleft", className="map-title") %>% # addControl(subtitle, position = "bottomleft", className="map-subtitle") %>% addProviderTiles(providers$Stadia.AlidadeSmooth) %>% + addPolygons(data = County_Crash_geom, + color = "black", + weight = 1, + fill = FALSE, + group = "Crash Points") %>% addMarkers(data = WI_schools, lng=WI_schools$LON, lat = WI_schools$LAT, + icon = school_symbol, label = lapply(paste0("", WI_schools$SCHOOL, " School
", WI_schools$DISTRICT, " School District
", WI_schools$SCHOOLTYPE), htmltools::HTML), @@ -193,16 +203,16 @@ wisconsin_crash_map <- Pedestrian_Crash_Data$vulnerable_role, " age: ", Pedestrian_Crash_Data$PedestrianAge), htmltools::HTML), group = "Crash Points") %>% addLegend(position = "bottomleft", labels = injury_severity$InjSevName, colors = injury_severity$color, group = "Crash Points", title = "Injury Severity") %>% - addCircleMarkers(data = County_Crash_geom, - lng=County_Crash_geom$longitude, - lat=County_Crash_geom$latitude, - #fillColor=county_pal(County_Crash_geom$CrashesPerPopulation), - radius=County_Crash_geom$value/20000, - stroke = TRUE, - color = "black", - weight = 1, - fillOpacity = 0.5, - group = "Counties") %>% +# addCircleMarkers(data = County_Crash_geom, +# lng=County_Crash_geom$longitude, +# lat=County_Crash_geom$latitude, +# #fillColor=county_pal(County_Crash_geom$CrashesPerPopulation), +# radius=County_Crash_geom$value/20000, +# stroke = TRUE, +# color = "black", +# weight = 1, +# fillOpacity = 0.5, +# group = "Counties") %>% addPolygons(data = County_Crash_geom, color = "black", weight = 1, @@ -213,12 +223,15 @@ wisconsin_crash_map <- "average crashes per year: ", round(County_Crash_geom$MeanCrashes,0), "
", "average crashes/year per 100k residents: ", round(County_Crash_geom$CrashesPerPopulation,0)), htmltools::HTML), group = "Counties") %>% - addLegend(position = "bottomleft", pal = county_pal, values = County_Crash_geom$CrashesPerPopulation, group = "Counties", title = "Circle size = county population

Color = Crashes/year
(normalized per 100k residents)") %>% + addLegend(position = "bottomleft", pal = county_pal, values = County_Crash_geom$CrashesPerPopulation, group = "Counties", title = "Crashes/year
(normalized per 100k residents)") %>% # addLegendSize(position = "bottomright", color = "black", shape = "circle", values = County_Crash_geom$value, group = "Counties", title = "Total crashes") %>% groupOptions(group = "Schools", zoomLevels = 13:20) %>% groupOptions(group = "Crash Points", zoomLevels = 10:20) %>% groupOptions(group ="Counties", zoomLevels = 1:9) + +wisconsin_crash_map saveWidget(wisconsin_crash_map, file = "figures/dynamic_crash_maps/wisconsin_pedestrian_crash_map.html", selfcontained = TRUE) +