-
Notifications
You must be signed in to change notification settings - Fork 4
/
ExtractStorms.Rmd
201 lines (151 loc) · 6.5 KB
/
ExtractStorms.Rmd
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
title: "Extract Storms"
output: rmarkdown::html_vignette
date: "`r Sys.Date()`"
vignette: >
%\VignetteIndexEntry{Extract Storms}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
``` {r setup, include = FALSE}
library(StormR)
library(terra)
library(rworldxtra)
data("countriesHigh")
```
The `defStormsList()` function allows to extract tropical cyclone track data for a
given tropical cyclone or set of tropical cyclones nearby a given location of
interest (`loi`). The `loi` can be defined using a country name, a specific
point (defined by its longitude and latitude coordinates), or any user imported
or defined spatial polygon shapefiles. By default only observations located
within 300 km around the `loi` are extracted but this can be changed using the
`max_dist` argument. Users can also extract tropical cyclones using the `name`
of the storm or the `season` during which it occurred. If both the `name` and
the `season` arguments are not filled then the `defStormsList()` function extracts all
tropical cyclones since the first cyclonic season in the database. Once the data
are extracted, the `plotStorms()` function can be used to visualize the
trajectories and points of observation of extracted tropical cyclones on a map.
In the following example we use the `test_dataset` provided with the package to
illustrate how cyclone track data can be extracted and visualised using country
and cyclone names, specific point locations, and polygon shapefiles, as
described below.
### Getting and ploting tropical cyclone track data
#### Using country names
We extract data on the tropical cyclone Pam (2015) nearby Vanuatu as follows:
``` {r chunk1}
sds <- defStormsDataset(verbose = 0)
st <- defStormsList(sds = sds, loi = "Vanuatu", names = "PAM", verbose = 0)
```
The `defStormsList()` function returns a `stormsList` object in which the first slot
`@data` contains a list of `Storm` objects. With the above specification the
`stormsList` contains only one `Storm` object corresponding to cyclone PAM and
the track data can be obtained using the `getObs()` function as follows:
``` {r chunk2}
head(getObs(st, name = "PAM"))
```
The number of observation and the indices of the observations can be obtained
using the `getNbObs()` and `getInObs()` as follows:
``` {r chunk3}
getNbObs(st, name = "PAM")
getInObs(st, name = "PAM")
```
The data can be visualised on a map as follows:
``` {r chunk4}
plotStorms(st, labels = TRUE)
```
#### Using a specified point location
We can extract all tropical cyclones near Nouméa (longitude = 166.45, latitude =
-22.27) between 2015 and 2021 as follows:
``` {r chunk5}
pt <- c(166.45, -22.27)
st <- defStormsList(sds = sds, loi = pt, seasons = c(2015, 2021), verbose = 0)
```
The number, the names, and the season of occurrence of the storms in the
returned `stormsList` object can be obtained using the `getNbStorms()`,
`getNames()`, and `getSeasons()` functions as follows:
``` {r chunk6}
getNbStorms(st)
getNames(st)
getSeasons(st)
```
We can plot track data for the topical cyclone Niran only using the `names`
argument of the `plotStorms()` function as follows:
``` {r chunk7}
plotStorms(st, names = "NIRAN", labels = TRUE, legends = "bottomleft")
```
The track data for Niran can also be extracted and stored in a new object using
the `getStorm()` function as follows:
``` {r chunk8}
NIRAN <- getStorm(st, name = "NIRAN")
getNames(NIRAN)
```
#### Using a user defined spatial polygon shapefile
We can extract all tropical cyclones that occurred between 2015 and 2021 near
the New Caledonia exclusive economic zone using the `eezNC` shapefile provided
with the `StormR` package as follows:
``` {r chunk9}
sp <- eezNC
st <- defStormsList(sds = sds, loi = eezNC, season = c(2015, 2021), verbose = 0)
```
Information about the spatial extent of the track data exaction can be obtained
using the `getLOI()`, `getBuffer()`, and `getBufferSize()` functions as follows:
``` {r chunk10}
LOI <- getLOI(st)
Buffer <- getBuffer(st)
BufferSize <- getBufferSize(st)
terra::plot(Buffer, lty = 3, main = paste(BufferSize, "km buffer arround New Caledonian EEZ", sep = " "))
terra::plot(LOI, add = TRUE)
terra::plot(countriesHigh, add = TRUE)
```
### Using different wind scale
By default the Saffir-Simpson hurricane wind scale (SSHS) is used in `defStormsList()`
to assign level to storms.
The maximum level reached in the scale for each cyclone
can then be obtained using the `getScale()` function as follows:
``` {r chunk11}
getScale(st)
```
In this case, the SSHS scale is composed of 6 thresholds resulting in 6 levels
spanning from level 0 to level 6.
We can only plot cyclones that reached level 5 and 6 using the `category`
argument of the `plotStorms()` function as follows:
``` {r chunk12}
plotStorms(st, category = c(5, 6), labels = FALSE, legends = "topright")
```
Finally, the user can choose his own scale and associated palette, by setting the `scale` and `scalePalette` inputs in `defStormsList()`. In the following example, we use the Tokyo's tropical cyclone intensity scale to analyse tropical storm PAM.
StormR provides default palette and category names:
```{r chunk 12}
# Tokyo's tropical cyclone intensity scale
RSMCScale <- c(16.94, 24.44, 32.5, 43.33, 53.61)
sts_jpn <- defStormsList(sds = sds,
loi = "Vanuatu",
names = "PAM",
scale = RSMCScale,
verbose = 0)
plotStorms(sts_jpn)
```
But you can also easily customize them:
```{r chunk 13}
RSMCPalette <- c("#6ec1ea", "#4dffff", "#c0ffc0", "#ffd98c", "#ff738a", "#a188fc")
names(RSMCPalette) <- c("Tropical depression",
"Tropical storm",
"Severe tropical storm",
"Typhoon",
"Very strong typhoon",
"Violent typhoon")
sts_jpn <- defStormsList(sds = sds,
loi = "Vanuatu",
names = "PAM",
scale = RSMCScale,
scalePalette = RSMCPalette,
verbose = 0)
plotStorms(sts_jpn)
```
#### Dynamic plot
`plotStorms` allows the user to dynamically plot tracks within an interactive map using leaflet
library by setting `dynamicPlot` to `TRUE`. Doing so, the user can explore the map the way he wants
and click and each dotted colored observations to see there informations.
``` {r chunk13}
# Example of dynamic plot, using the same parameters above
plotStorms(st, category = c(4, 5), labels = FALSE, legends = "topright", dynamicPlot=TRUE)
```