-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
85 lines (61 loc) · 2.45 KB
/
README.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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
[![Travis-CI Build Status](https://travis-ci.org/sebdalgarno/HGfetch.svg?branch=master)](https://travis-ci.org/sebdalgarno/HGfetch)
# haidawave
## Introduction
`haidawave` is as R package to calculate wave exposure (mean fetch) based on fetch and possibly wind data.
In addition to the `mean_fetch`, `wind_weights` and `weighted_fetch` functions, which are demonstrated below,
it also provides the `convert_proj` function to convert latitudes and longitudes
to eastings and northings in BC Albers (or a projection of the users choice);
the `nearest_point` function to join one data frame to another based on the shortest
euclidean distance between their coordinates; and the `hg_fetch` and `hg_wind`
to download the complete fetch and wind datasets for Haida Gwaii.
## Demonstration
```{r, message = FALSE}
library(haidawave)
library(magrittr)
library(ggplot2)
library(ggthemes)
library(RColorBrewer)
library(plyr)
library(dplyr)
# only consider points for Reef Island, Laskeek Bay, British Coluumbia
laskeek_fetch <- filter(haidawave::laskeek_fetch, Easting > 627000 & Northing < 890000)
# calculate mean fetch for each point
fetch <- ddply(laskeek_fetch, c("Easting", "Northing"), mean_fetch)
# Plot mean Fetch
gp <- ggplot(fetch) + geom_point(aes(x = Easting, y = Northing, color = Fetch), size = 0.5) +
coord_fixed() +
theme_few() +
scale_color_distiller(palette = "Spectral")
print(gp)
# get wind weights by station and direction
cumshewa_wind <- ddply(haidawave::cumshewa_wind, c("Station"), wind_weights) %>% as.tbl()
cumshewa_wind
# averge fetch bearings by 10 degree increments so consistent with wind directions
laskeek_fetch %<>% mutate(Bearing = (Bearing + 5) %/% 10 * 10)
# bind wind weights
laskeek_fetch %<>% left_join(cumshewa_wind, by = c("Bearing" = "Direction"))
laskeek_fetch
# calculate mean weighted fetch
laskeek_fetch %<>% ddply(c("Easting", "Northing"), weighted_fetch) %>% as.tbl()
print(gp %+% laskeek_fetch)
```
## Installation
To install the latest version from GitHub
```
# install.packages("devtools")
devtools::install_github("sebdalgarno/haidawave")
```
## Contribution
Please report any [issues](https://github.com/sebdalgarno/haidawave/issues).
[Pull requests](https://github.com/sebdalgarno/haidawave/pulls) are always welcome.