mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
modify storm track to show status by color
This commit is contained in:
+98
-36
@@ -241,10 +241,10 @@ Col {data-width=500 .tabset}
|
||||
### Track Map {.no-padding}
|
||||
```{r}
|
||||
# Overview - Track Map
|
||||
# TODO: implement hurricane category status
|
||||
|
||||
storm_track <- reactive({
|
||||
req(storm_selection$is_selected)
|
||||
|
||||
result <- get_hurdat_track(storm_selection)
|
||||
|
||||
return(result)
|
||||
@@ -277,42 +277,104 @@ observe({
|
||||
lat = c(35)
|
||||
)
|
||||
}
|
||||
|
||||
# HURDAT storm status
|
||||
# TD – Tropical cyclone of tropical depression intensity (< 34 knots)
|
||||
# TS – Tropical cyclone of tropical storm intensity (34-63 knots)
|
||||
# HU – Tropical cyclone of hurricane intensity (> 64 knots)
|
||||
# EX – Extratropical cyclone (of any intensity)
|
||||
# SD – Subtropical cyclone of subtropical depression intensity (< 34 knots)
|
||||
# SS – Subtropical cyclone of subtropical storm intensity (> 34 knots)
|
||||
# LO – A low that is neither a tropical cyclone, a subtropical cyclone, nor an extratropical cyclone (of any intensity)
|
||||
# WV – Tropical Wave (of any intensity)
|
||||
# DB – Disturbance (of any intensity)
|
||||
|
||||
# Line Color Storm Type Status Pressure (mb) Wind (mph) Wind (knots)
|
||||
# Blue Subtropical Depression SD -- <=38 <=33
|
||||
# Light Blue Subtropical Storm SS -- 39-73 34-63
|
||||
# Green Tropical Depression (TD) TD -- <=38 <=33
|
||||
# Yellow Tropical Storm (TS) TS 980+ 39-73 34-63
|
||||
# Red Hurricane (Cat 1) HU <=980 74-95 64-82
|
||||
# Pink Hurricane (Cat 2) HU 965-980 96-110 83-95
|
||||
# Magenta Major Hurricane (Cat 3) HU 945-965 111-129 96-112
|
||||
# Purple Major Hurricane (Cat 4) HU 920-945 130-156 113-136
|
||||
# White Major Hurricane (Cat 5) HU <=920 157+ 137+
|
||||
# Green dashed (- -) Wave/Low/Disturbance WV/LO/DB -- -- --
|
||||
# Black hatched (++) Extratropical Cyclone EX -- -- --
|
||||
|
||||
storm_track <- storm_track %>%
|
||||
mutate(
|
||||
line_color = case_when(
|
||||
storm_status == "TD" ~ "green",
|
||||
storm_status == "TS" ~ "#FFDF00",
|
||||
storm_status == "HU" ~ "magenta",
|
||||
storm_status == "EX" ~ "black",
|
||||
storm_status == "SD" ~ "blue",
|
||||
storm_status == "SS" ~ "lightblue",
|
||||
storm_status == "LO" ~ "green",
|
||||
storm_status == "WV" ~ "green",
|
||||
storm_status == "DB" ~ "green",
|
||||
TRUE ~ "gray"
|
||||
)
|
||||
)
|
||||
|
||||
proxy <- leafletProxy("track_map") %>%
|
||||
clearShapes() %>%
|
||||
clearMarkers() %>%
|
||||
setView(
|
||||
lng = map_center$lon,
|
||||
lat = map_center$lat,
|
||||
zoom = 4
|
||||
)
|
||||
|
||||
if (nrow(storm_track) >= 2) {
|
||||
storm_track <- storm_track %>% arrange(datetime)
|
||||
|
||||
leafletProxy("track_map", data = storm_track) %>%
|
||||
clearShapes() %>%
|
||||
clearMarkers() %>%
|
||||
setView(
|
||||
lng = map_center$lon,
|
||||
lat = map_center$lat,
|
||||
zoom = 4
|
||||
) %>%
|
||||
addPolylines(
|
||||
data = storm_track,
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
weight = 4,
|
||||
color = "blue"
|
||||
) %>%
|
||||
addCircleMarkers(
|
||||
data = storm_track %>% filter(record_identifier == "L"),
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
radius = 5,
|
||||
weight = 0,
|
||||
color = "red",
|
||||
fillColor = "red",
|
||||
fillOpacity = 0.8
|
||||
) %>%
|
||||
addCircles(
|
||||
data = storm_track %>% filter(record_identifier == "L"),
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
radius = ~rmw_meters,
|
||||
weight = 2,
|
||||
color = "red",
|
||||
fillColor = "red",
|
||||
fillOpacity = 0.3
|
||||
)
|
||||
for (i in 1:(nrow(storm_track) - 1)) {
|
||||
segment_data <- storm_track[i:(i+1), ]
|
||||
|
||||
proxy <- proxy %>%
|
||||
addPolylines(
|
||||
data = segment_data,
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
weight = 2,
|
||||
color = storm_track$line_color[i],
|
||||
opacity = 0.8
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
proxy %>%
|
||||
addCircleMarkers(
|
||||
data = storm_track,
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
radius = 1,
|
||||
color = ~line_color,
|
||||
fillOpacity = 0.8,
|
||||
popup = ~storm_status
|
||||
) %>%
|
||||
addCircleMarkers(
|
||||
data = storm_track %>% filter(record_identifier == "L"),
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
radius = 5,
|
||||
weight = 0,
|
||||
color = "red",
|
||||
fillColor = "red",
|
||||
fillOpacity = 0.8
|
||||
) %>%
|
||||
addCircles(
|
||||
data = storm_track %>% filter(record_identifier == "L"),
|
||||
lng = ~lon,
|
||||
lat = ~lat,
|
||||
radius = ~rmw_meters,
|
||||
weight = 2,
|
||||
color = "red",
|
||||
fillColor = "red",
|
||||
fillOpacity = 0.3
|
||||
)
|
||||
})
|
||||
|
||||
leafletOutput("track_map", height = "100%")
|
||||
|
||||
Reference in New Issue
Block a user