knitr::opts_chunk$set(echo = TRUE)
The bangarang
package is a bundle of datasets and functions that help analysts with research in the Kitimat Fjord System (KFS) in the north coast of mainland British Columbia. Nearly all of the content is catered specifically to analysis of datasets from the RV Bangarang expedition of 2013 - 2015, which was focused on the abundance, distribution, and foraging ecology of whales, seabirds, salmon, and their prey during the months of summer and early fall. The research involved line-transect sampling, active acoustic (echosounder) surveys, and oceanographic sampling (both while underway and at a grid of stations).
Methodological details can be found here. More info on the Bangarang project can be found here. The Bangarang project was carried out as a doctoral thesis at Scripps Institution of Oceanography in close collaboration with the Gitga'at First Nation, BC Whales, Fisheries & Oceans Canada, and the NOAA Southwest Fisheries Science Center.
The bangarang
package can be downloaded directly from GitHub
:
# Install devtools if needed if (!require('devtools')) install.packages('devtools') # Install package devtools::install_github('ericmkeen/bangarang')
Load into your R
session:
library(bangarang)
This vignette was made with bangarang
version r utils::packageVersion('LTabundR')
, and will make use of a few other packages:
library(tidyverse) library(ggplot2)
Produce a map of the Bangarang study area in the KFS using the ggplot
and sf
packages:
gg_kfs()
As with all the bangarang
functions, see this function's documentation for changing the geographic range, color, and transparency settings.
?gg_kfs
data(kfs_land)
kfs_land %>% class kfs_land %>% glimpse
Snapshot of dataset:
par(mar=c(.1,.1,.1,.1)) kfs_land %>% plot
data(kfs_seafloor) kfs_seafloor %>% glimpse
Plot it:
ggplot(kfs_seafloor, aes(x=x, y=y, color=layer)) + geom_point(size=.1) + xlab(NULL) + ylab(NULL) + labs(color = 'Depth (m)') + theme_minimal()
data(shiplane) shiplane %>% glimpse
Plot it:
gg_kfs() + geom_path(data=shiplane, mapping=aes(x=X, y=Y, group=PID)) + xlab(NULL) + ylab(NULL)
data(provinces) provinces %>% glimpse
Check it out:
gg_kfs() + geom_polygon(data=provinces, mapping=aes(x=X, y=Y, group = factor(province), fill = factor(province), color = factor(province)), alpha=.4) + xlab(NULL) + ylab(NULL) + labs(fill='Province', color='Province')
data(channels) channels %>% glimpse
Check it out:
gg_kfs() + geom_polygon(data=channels, mapping=aes(x=X, y=Y, fill = province, color = province), alpha=.4) + xlab(NULL) + ylab(NULL)
data(kfs_blocks_bbox) kfs_blocks_bbox %>% glimpse
Check it out:
gg_kfs() + geom_rect(data=kfs_blocks_bbox, mapping=aes(xmin=left, xmax=right, ymin=bottom, ymax=top, group=id), fill=NA, color='black') + xlab(NULL) + ylab(NULL)
data(blocks) blocks %>% glimpse
Check it out:
gg_kfs() + geom_rect(data=blocks, mapping=aes(xmin=left, xmax=right, ymin=bottom, ymax=top, group=name), fill=NA, color='black') + xlab(NULL) + ylab(NULL)
data(stations) stations %>% glimpse
Check it out:
gg_kfs() + geom_point(data=stations, mapping=aes(x=long, y=lat, group = block), alpha=.8) + xlab(NULL) + ylab(NULL) + labs(group='Waterway')
All survey effort aboard the Bangarang:
data(effort) effort %>% glimpse
Map overview:
gg_kfs() + geom_point(data=effort, mapping=aes(x=lon, y=lat, color = effort), alpha=.4, size=.2) + xlab(NULL) + ylab(NULL)
Show each year separately:
gg_kfs() + geom_point(data=effort, mapping=aes(x=lon, y=lat, color = effort), alpha=.4, size=.2) + facet_wrap(~lubridate::year(date)) + xlab(NULL) + ylab(NULL) + theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank())
Show each circuit in 2015 separately, systematic transect effort only:
# Filter to transect effort only transects <- effort %>% filter(lubridate::year(date) == 2015, effort == 'transect') %>% mutate(group = paste0(lubridate::year(date), ' circuit ', circuit)) # plot it gg_kfs() + geom_point(data= transects, mapping=aes(x=lon, y=lat), alpha=.4, size=.2) + facet_wrap(~group) + xlab(NULL) + ylab(NULL) + theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank())
data(seabirds) seabirds %>% glimpse
Map it:
gg_kfs() + geom_point(data=seabirds, mapping=aes(x=lon, y=lat, color = sp1, size = best), alpha=.4) + xlab(NULL) + ylab(NULL)
data(salmon) salmon %>% glimpse
Map it;
gg_kfs() + geom_point(data=salmon, mapping=aes(x=lon, y=lat, size = jumps), alpha=.4) + xlab(NULL) + ylab(NULL)
ggplot(salmon %>% filter(zone < 3) %>% mutate(Zone = factor(zone)), aes(x=Zone)) + geom_bar(stat='count')
data(whale_sightings) whale_sightings %>% glimpse
gg_kfs() + geom_point(data=whale_sightings, mapping=aes(x=x, y=y, color = spp, size = size), alpha=.4) + xlab(NULL) + ylab(NULL)
This dataset is an interpolated grid of oceanographic values for each circuit in each year. Some variables are from the thermosalinograph we had running at the surface during transects, some are from the echosounder we used while underway, and others are from the Seabird Electronics CTD we used at the grid of oceanographic stations.
data(ocean) ocean %>% glimpse
Here are the variables included:
ocean$metric %>% unique %>% sort
As an example, say we wanted a map of the sea surface salinity (SSS
) for each circuit of the 2015 season.
# Filter the dataset sss <- ocean %>% filter(metric == 'SSS', year==2015) # Map it gg_kfs() + geom_point(data=sss, mapping=aes(x=lon, y=lat, color=value), size=.05) + facet_wrap(~circuit) + xlab(NULL) + ylab(NULL) + theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) + scale_color_gradientn(colours = rev(rainbow(5)))
in_block()
A way to see which geostratum a pair of coordinates is located within.
in_block(x= -129.4, y=53.2)
in_block(x= -129.2, y=52.9)
in_kfs()
A quick test to see if coordinates properly within the water within the boundaries of the KFS (as defined by the Bangarang project). The function returns the dataset with a new column, inkfs
:
test <- in_kfs(seabirds %>% rename(x=lon, y=lat), toplot = TRUE) test$inkfs %>% table
in_water()
A quick test to see if coordinates properly within the water within the water (and not on land by mistake). The function returns the dataset with a new column, valid
:
test <- in_water(seabirds %>% rename(x=lon, y=lat), toplot = TRUE) test$valid %>% table
whale_map()
Calculates the true position of a sighting within the KFS, in offshore or confined coastal waters, accounting for whether or not the observer is using the horizon or a shoreline as the basis for the reticle reading.
The X
and Y
you supply is the observer's location (either a boat or a stationary field station).
whalemap(X= -129.2, Y=52.9, bearing = 313, reticle = 0.2, eye.height = 2.1, vessel.hdg = 172, toplot=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.