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)
Column definitions:
date
: Date and time, in format YYYY-MM-DD HH:MM:SS
.
lat
: Latitude in decimal degrees.
lon
: Longitude in decimal degrees.
effort
: Code for search effort: "off"
= opportunistic sighting occurring while off search effort; "casual"
= opportunistic sighting occurring while transiting area while off seaerch effort; "station"
= opportunistic sighting while conducting sampling at oceanographic stations; "with whale"
= opportunistic sighting while conducting focal follows of whales; "transect"
= seabird detection during systematic line-transect effort. Analyses focused on density/abundance estimation should filter to "transect"
effort only.
bft
: Beaufort sea state, ranging from 0
(glassy calm) to 4
(white caps everywhere); this may be a useful covariate in a density/abundance model.
precip
: Precipitation state; another potentially useful covariate.
knots
: Ship speed in knots.
hdg
: Ship heading (range = 0 - 360 degrees).
wind_kph_raw
: Apparent wind speed, in kilometers per hour, as received by the shipboard weather station, unadjusted for ship speed or heading.
wind_hdg_raw
: Apparent wind heading, in degrees, as received by the shipboard weather station, unadjusted for ship speed or heading.
zone
: Category of distance from the vessel's track line, as estimated by a handheld rangefinder: Zone "1"
is 0 - 75m, Zone "2"
is 75m - 150m. The zone "OUT"
means the bird was estimated to be beyond 150m. The zone "221"
means that the bird was originally seen in Zone 2
but it approached as near as Zone 1 (either due to bird movement or ship approaching the bird). We recorded this note to test for a couple things: (1) If more birds are being observed in Zone 1 vs. Zone 2, that may mean that we are missing some birds in Zone 2 and our assumption that our strip width is 150m on either side of the vessel may be problematic; and (2) If more birds are being observed in Zone 2 than Zone 1, that may mean that birds are avoiding the vessel and some could even be flushing beyond Zone 2, which could also be problematic for density estimation.
line
: An indication of whether there was uncertainty about which zone
the bird occurred within; if MIDL
, the bird occurred right on the line between Zone 1 and Zone 2 by the observer's estimation; if OUTR
, the bird occurred right on the line between Zone 2 and beyond. If your analysis assumed a strip width of 150m on each side of the vessel, the sightings marked OUTR
may be of special interest: how drastically would your density estimates change if those sightings were included or excluded?
side
: The side of the vessel (PORT
or STARBOARD
) the bird was seen on. If the value is HELM
, that means the researcher at the data entry position at the helm detected the sighting. Likely not relevant to basic density/abundance estimation analyses.
best
: Best estimate of total flock size.
min
: Minimum estimate of total flock size.
max
: Maximum estimate of total flock size.
feed
: Indication of whether or not the birds are feeding: "M"
= Maybe; "N"
= No; "S"
= Some; "W"
= Unknown; "Y"
= Yes.
motion
: Indication of bird's motion behavior: "FLUSH"
= Birds were originally sitting but were flushed (either dove or flew off) in response to the research vessel; "FLY"
= Birds were in flight; "FOLO"
= Birds are following the research vessel (problematic for recounting!); "RAFT"
= Birds were rafting on surface debris, such as floating kelp or logs; "SIT"
= Birds were sitting on the water.
dir
: Indication of bird's flight direction (if flying); cardinal directions are typically used ("N"
, "NE"
, "E"
, "SE"
, "S"
, "SW"
, "W"
, "NW"
) with the exception of birds circling the vessel ("CIR"
or "CR"
).
height
: Estimate of bird's flight height above sea level, in meters. This is relevant because wind speed increases predictably with height above sea level.
sp1
: Four-letter species code for primary (and possibly only) species in the flock.
per1
: Percentage of total flock size that sp1
comprises.
plum1
: Primary plumage state for sp1
. Note that, in some cases, if a single species occurs in several different plumage state, the same species might be entered as sp1
, sp2
, and even sp3
. Codes: "AB"
or "ABE"
= Adult breeding, either/both sex(es); "ABF"
= Adult breeding, female; "ABM"
= Adult breeding, male; "ANE"
= Adult non-breeding, either/both sex(es); "FLE"
= Fledgling; "JV"
or "JVE"
= Juvenile; "MX"
= Mixture of unspecified plumages present; "NBE"
= Non-breeding, either/both sex(es); "OTH"
= Other unspecified plumage; "SA"
= Sub-adult plumage; "AAE"
or "AAM"
= unknown.
sp2
: If this is a mixed-species flock with two or more species present, this is the four-letter species code for the second species.
per2
: Percentage of total flock size that sp2
comprises, if present.
plum2
: Primary plumage state for sp2
, if present.
sp3
: If this is a mixed-species flock with three species present, this is the four-letter species code for the third species.
per3
: Percentage of total flock size that sp3
comprises, if present.
plum3
: Primary plumage state for sp3
, if present.
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.