knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
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.
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)
To install the latest version from GitHub
# install.packages("devtools") devtools::install_github("sebdalgarno/haidawave")
Please report any issues.
Pull requests are always welcome.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.