<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/rrricanes-to-access-tropical-cyclone-data/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://ropensci.org/blog/blog/2017/09/27/rrricanes"> rOpenSci Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>What is rrricanes</h2>
<h3>Why Write rrricanes?</h3>
<p>There is a tremendous amount of weather data available on the internet. Much of it is in raw format and not very easy to obtain. Hurricane data is no different. When one thinks of this data they may be inclined to think it is a bunch of map coordinates with some wind values and not much else. A deeper look will reveal structural and forecast data. An even deeper look will find millions of data points from hurricane reconnaissance, computer forecast models, ship and buoy observations, satellite and radar imagery, …</p>
<p><code>rrricanes</code> is an attempt to bring this data together in a way that doesn't just benefit R users, but other languages as well.</p>
<p>I began learning R in 2015 and immediately had wished I had a hurricane-specific dataset when Hurricane Patricia became a harmless, but historic hurricane roaming the Pacific waters. I found this idea revisited again as Hurricane Matthew took aim at Florida and the southeast in 2016. Unable to use R to study and consolidate Matthew's data in R led me to begin learning package development. Thus, the birth of <code>rrricanes</code>.</p>
<p>In this article, I will take you on a lengthy tour of the most important features of <code>rrricanes</code> and what the data means. If you have a background working with hurricane data, most of this will be redundant. My aim here is to cover the big ideas behind the package and explain them under the assumption you, the reader, are unfamiliar with the data offered.</p>
<p><code>rrricanes</code> <strong>is not intended to be used in emergency situations</strong>. I write this article as areas I have lived or currently live are under the gun from Hurricane Harvey and <code>rrricanes</code> is unable to obtain data due to external issues (I will describe these later). It is designed with the intent of answering questions and exploring ideas outside of a time-sensitive environment.</p>
<p><code>rrricanes</code> will not be available in CRAN for quite some time. The current schedule is May 15, 2018 (the &quot;start&quot; of the East Pacific hurricane season). This year is soley for testing under real-time conditions.</p>
<h3>And rrricanesdata</h3>
<p>The NHC archives text products dating back to at least 1998 (some earlier years exist but yet to be implemented in this package). Accessing this data is a time-consuming process on any computer. A limit of 4 requests per second is put in place to avoid being banned (or restricted) from the archives. So, if a hurricane has 20 text products you wish to pull and parse, this will take 5 seconds. Most cyclones have more and some, far more.</p>
<p><code>rrricanesdata</code> is a compliment package to <code>rrricanes</code>. <code>rrricanesdata</code> contains post-scraped datasets of the archives for all available storms with the exception of advisories issued in the current month.This means you can explore the various datasets without the wait.</p>
<p><code>rrricanesdata</code> will be updated monthly if an advisory has been issued the previous month. There will be regular monthly updates approximately from May through November – the typical hurricane season. In some cases, a cyclone may develop in the off-season. <code>rrricanesdata</code> will be updated on the same schedule.</p>
<h3>ELI5 the Data</h3>
<p>This package covers tropical cyclones that have developed in the Atlantic basin (north Atlantic ocean) or East Pacific basin (northeast Pacific east of 140#°W). Central Pacific (140#°W – 180#°W) may be mixed in if listed in the NHC archives.</p>
<p>While traditionally the hurricane season for each basin runs from mid-May or June through November, some cyclones have developed outside of this time frame.</p>
<p>Every tropical cylone (any tropical low whether classified as a tropical depression, tropical storm or hurricane) contains a core set of text products officially issued from the National Hurricane Center. These products are issued every six hours.</p>
<p>Much of this data has changed in format over the years. Some products have been discontinued and replaced by new products or wrapped into existing products. Some of these products are returned in raw text format; it is not cleaned and may contain HTML characters. Other products are parsed with every piece of data extracted and cleaned.</p>
<p>I have done my best to ensure data is high quality. But, I cannot guarantee it is perfect. If you do believe you have found an error, please <a rel="nofollow" href="https://github.com/ropensci/rrricanes/issues" target="_blank">let me know</a>; even if it seems small. I would rather be notified of a false error than ignore a true one.</p>
<h4>The Products</h4>
<p>Each advisory product is listed below with an abbreviation in parentheses. Unless otherwise noted, these products are issued every six hours. Generally, the times issued are 03:00, 09:00, 15:00 and 21:00 UTC. Some products may be issued in three-hour increments and, sometimes, two-hour increments. <code>update</code> can be issued at any time.</p>
<ul>
<li>
<p>Storm Discussion (<code>discus</code>) – These are technical discussions centered on the current structure of the cyclone, satellite presentation, computer forecast model tendencies and more. These products are not parsed.</p>
</li>
<li>
<p>Forecast/Adivsory (<code>fstadv</code>) – This data-rich product lists the current location of the cyclone, its wind structure, forecast and forecast wind structure.</p>
</li>
<li>
<p>Public Advisory (<code>public</code>) – These are general text statements issued for the public-at-large. Information in these products is a summary of the Forecast/Advisory product along with any watches and warnings issued, changed, or cancelled. Public Advisory products are the only regularly-scheduled product that may be issued intermittently (every three hours and, occasionally, every two hours) when watches and warnings are in effect. These products are not parsed.</p>
</li>
<li>
<p>Wind Speed Probabilities (<code>wndprb</code>) – These products list the probability of a minimum sustained wind speed expected in a given forecast window. This product replaces the Strike Probabilities product beginning in 2006 (see below).</p>
</li>
<li>
<p>Updates (<code>update</code>) – Tropical Cyclone Updates may be issued at any time if a storm is an immediate threat to land or if the cyclone undergoes a significant change of strength or structure. The information in this product is general. These products are not parsed.</p>
</li>
</ul>
<h4>Discontinued Products</h4>
<ul>
<li>
<p>Strike Probabilities (<code>prblty</code>) – List the probability of a tropical cyclone passing within 65 nautical miles of a location within a forecast window. Replaced in 2006 by the Wind Speed Probabilities product.</p>
</li>
<li>
<p>Position Estimates (<code>posest</code>) – Typically issued as a storm is threatening land but generally rare (see Hurricane Ike 2008, Key AL092008). It is generally just an update of the current location of the cyclone. After the 2011 hurricane season, this product was discontinued; Updates are now issued in their place. These products are not parsed.</p>
</li>
</ul>
<h4>Primary Key</h4>
<p>Every cyclone has a <code>Key</code>. However, not all products contain this value (<code>prblty</code>, for example). Products issued during and after the 2005 hurricane season contain this variable.</p>
<p>Use <code>Key</code> to tie datasets together. If <code>Key</code> does not exist, you will need to use a combination of <code>Name</code> and <code>Date</code>, depending on your requirements. Keep in mind that, unless a name is retired, names are recycled every seven years. For example, there are multiple cyclones named Katrina but you may want to isolate on Katrina, 2005.</p>
<h2>Installation</h2>
<p><code>rrricanes</code> will not be submitted to CRAN until prior to the hurricane season, 2018. It can be installed via github using <code>devtools</code>:</p>
<div>
<pre><code data-lang="r"><span></span>devtools<span>::</span>install_github<span>(</span><span>&quot;ropensci/rrricanes&quot;</span><span>,</span> build_vignettes <span>=</span> <span>TRUE</span><span>)</span>
</code></pre>
</div>
<h3>Optional Supporting Packages</h3>
<p><code>rrricanesdata</code> uses a drat repository to host the large, pre-processed datasets.</p>
<div>
<pre><code data-lang="r"><span></span>install.packages<span>(</span><span>&quot;rrricanesdata&quot;</span><span>,</span>
                 repos <span>=</span> <span>&quot;https://timtrice.github.io/drat/&quot;</span><span>,</span>
                 type <span>=</span> <span>&quot;source&quot;</span><span>)</span>
</code></pre>
</div>
<p>To use high resolution tracking charts, you may also wish to install the `rnaturalearthhires' package:</p>
<div>
<pre><code data-lang="r"><span></span>install.packages<span>(</span><span>&quot;rnaturalearthhires&quot;</span><span>,</span>
                 repos <span>=</span> <span>&quot;http://packages.ropensci.org&quot;</span><span>,</span>
                 type <span>=</span> <span>&quot;source&quot;</span><span>)</span>
</code></pre>
</div>
<p>Linux users may also need to install:</p>
<ul>
<li><code>libgdal-dev</code></li>
<li><code>libproj-dev</code></li>
<li><code>libxml2-dev</code></li>
</ul>
<h2>Get a List of Storms</h2>
<p>We start exploring <code>rrricanes</code> by finding a storm (or storms) we wish to analyze. For this, we use <code>get_storms</code>. There are two optional parameters:</p>
<ul>
<li>
<p><code>years</code> Between 1998 and current year</p>
</li>
<li>
<p><code>basins</code> One or both &quot;AL&quot; and &quot;EP&quot;</p>
</li>
</ul>
<p>An empty call to the function will return storms for both the Atlantic and East Pacific basin for the current year.</p>
<div>
<pre><code data-lang="r"><span></span><span>library</span><span>(</span>dplyr<span>)</span>
<span>library</span><span>(</span>rrricanes<span>)</span>
get_storms<span>()</span> <span>%>%</span> <span>print</span><span>(</span>n <span>=</span> <span>nrow</span><span>(</span><span>.</span><span>))</span>
</code></pre>
</div>
<div>
<pre><code data-lang="text"><span></span>## # A tibble: 33 x 4
##     Year                           Name Basin
##    </code></pre></div>