-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwind.qmd
156 lines (126 loc) · 5.86 KB
/
wind.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
execute:
warning: false
error: false
cache: true
---
# `stormwindmodel` for Harvey
## Data Procurement
* Hurricane track data was downloaded from the `hurricaneexposuredata` package using the `data("hurr_tracks")` command. This data originates from the [HURDAT2](https://www.nhc.noaa.gov/data/).
* ZCTA to County Crosswalk was downloaded from <https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt>
* ZCTA shapefiles were downloaded for the entire US using the `tigris` package
A vignette for the `hurricaneexposuredata` package can be found [here](https://cran.r-project.org/web/packages/hurricaneexposure/vignettes/hurricaneexposure.html)
## Data Processing
The `stormwindmodel` estimates wind exposure for points. In this case we used wind exposure at ZCTA geometric centroids to estimate wind exposure for the entire ZCTA.
1. Hurricane data was downloaded using `hurricaneexposuredata` package using the `data("hurr_tracks")` command and filtered using the Harvey Automated Tropical Cyclone Forecasting code (AL092017)
2. Separately, 2017 ZCTAs downloaded from the [US Census Cartographic Boundary Files](https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.2017.html#list-tab-1556094155)
3. Then, the ZCTAs were joined to the [US Census ZCTA to County Crosswalk](https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt) in order to identify Texas and Louisiana ZCTAs
4. The ZCTAs were filtered to Texas and Louisiana
5. Geometrics centroids were calculated for each ZCTA
6. The `calc_grid_winds` and `summarize_grid_winds` commands were used to calculate wind exposure for each centroid. It works by
a. Imputing the hurricane track to every 15 minutes
b. Adding the wind radii from the [HURDAT2](https://www.nhc.noaa.gov/data/)
c. Modeling wind exposure for each point
More information about the `stormwindmodel` package and variables calculated are included in this [vignette](https://cran.r-hub.io/web/packages/stormwindmodel/vignettes/Details.html)
## Output
- `TXLA_ZCTA_AL092017_stormwindmodel`
- **GEOID** - ZCTA
- **date_time_max_wind** - UTC date & time where maximum wind was sustained
- **vmax_sust** - Maximum 10-m 1-min sustained wind for the tropical cyclone (m/s)
- **vmax_gust** - Max 10-m 1-min gust wind experienced at grid point (m/s)
- **sust_dur** - Duration of time a certain sustained wind was experienced at grid point (minutes)
- **gust_dur** - Duration of time a certain gust wind was experienced at grid point (minutes)
## Code
Storm track data is filtered for Hurricane Harvey
```{r}
library(hurricaneexposuredata)
library(stormwindmodel)
library(tidyverse)
data("hurr_tracks")
AL092017_track <- hurr_tracks %>%
filter(usa_atcf_id == "AL092017") %>%
select(-c(storm_id, usa_atcf_id))
```
ZCTA geo-centoids were calculated
```{r}
#| output: false
library(tigris)
library(sf)
ZCTAs <- read_csv("https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt") %>%
filter(STATE %in% c(48, 22)) %>%
distinct(ZCTA5) %>%
rename(GEOID = ZCTA5)
ZCTAs_sf <- ZCTAs %>%
left_join(zctas(cb = FALSE, year = 2017), by = join_by(GEOID == GEOID10)) %>%
st_as_sf() %>%
select(-c(ZCTA5CE10, CLASSFP10, MTFCC10, FUNCSTAT10, ALAND10, AWATER10, INTPTLAT10, INTPTLON10))
ZCTAs_center <- ZCTAs_sf %>%
st_transform("ESRI:102003") %>%
st_centroid() %>%
st_transform("EPSG:4269")
ZCTAs_centers_df <- ZCTAs_center %>%
mutate(gridid = GEOID,
glat = map_dbl(geometry, function(geo) st_coordinates(geo)[[2]]),
glon = map_dbl(geometry, function(geo) st_coordinates(geo)[[1]]),
glandsea = as.logical(1)) %>%
select(gridid, glat, glon, glandsea) %>%
st_drop_geometry()
```
Geo-centroids
```{r}
ggplot() +
geom_sf(data = ZCTAs_sf) +
geom_sf(data = ZCTAs_center, color = "red", size = 0.6) +
coord_sf(crs = st_crs("ESRI:102003"))
```
Calculated wind exposure
```{r}
AL092017_grid_winds <- calc_grid_winds(hurr_track = AL092017_track,
grid_df = ZCTAs_centers_df)
# parsing error was present in the package's code
summarize_grid_winds_fix <- function (grid_winds, gust_duration_cut = 20, sust_duration_cut = 20,
tint = 0.25) {
calc_sust_dur <- function(wind) {
60 * tint * sum(wind > sust_duration_cut, na.rm = TRUE)
}
calc_gust_dur <- function(wind) {
60 * tint * sum(wind > gust_duration_cut, na.rm = TRUE)
}
grid_wind_summary <- tibble::tibble(gridid = colnames(grid_winds),
date_time_max_wind = rownames(grid_winds)[apply(grid_winds,
MARGIN = 2, FUN = which.max)], vmax_sust = apply(grid_winds,
MARGIN = 2, FUN = max, na.rm = TRUE), vmax_gust = .data$vmax_sust *
1.49, sust_dur = apply(grid_winds, MARGIN = 2, FUN = calc_sust_dur),
gust_dur = apply(grid_winds, MARGIN = 2, FUN = calc_gust_dur)) %>%
dplyr::mutate(date_time_max_wind = ifelse(.data$vmax_sust ==
0, NA, .data$date_time_max_wind))
return(grid_wind_summary)
}
AL092017_winds <- summarize_grid_winds_fix(AL092017_grid_winds$vmax_sust) %>%
rename(GEOID = gridid)
```
```{r}
#| output: false
AL092017_winds_sf <- AL092017_winds %>%
left_join(zctas(cb = FALSE, year = 2017), by = join_by(GEOID == GEOID10)) %>%
st_as_sf() %>%
mutate(date_time_max_wind = as_datetime(date_time_max_wind)) %>%
select(-c(ZCTA5CE10, CLASSFP10, MTFCC10, FUNCSTAT10, ALAND10, AWATER10, INTPTLAT10, INTPTLON10))
```
Plotted wind measures
```{r}
library(gridExtra)
output_maps <- c("vmax_sust", "vmax_gust", "sust_dur", "gust_dur", "date_time_max_wind") %>%
map(~
AL092017_winds_sf %>%
ggplot() +
geom_sf(aes(fill = !!sym(.x)), color = NA) +
coord_sf(crs = st_crs("ESRI:102003"))
)
do.call(grid.arrange, c(output_maps, ncol = 2))
```
```{r}
#| output: false
AL092017_winds %>%
st_write("output/TXLA_ZCTA_stormwindmodel.gpkg", "TXLA_ZCTA_stormwindmodel", append = FALSE)
```