-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
291 lines (225 loc) · 8.93 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
[![Build Status](https://travis-ci.org/ices-tools-dev/sfdSAR.svg?branch=master)](https://travis-ci.org/ices-tools-dev/sfdSAR)
[<img align="right" alt="ICES Logo" width="17%" height="17%" src="http://ices.dk/_layouts/15/1033/images/icesimg/iceslogo.png">](http://ices.dk)
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
# sfdSAR
The goal of sfdSAR is to make it easy to follow the procedure of calculating swept
area ratio of an area of seabed by a fishing gear.
## Installation
You can install the sfdSAR using
```r
install.packages("sfdSAR", repos = "https://ices-tools-prod.r-universe.dev")
```
## Usage
For a summary of the package:
```r
library(sfdSAR)
?sfdSAR
```
## References
ICES 2015. Report of the Working Group on Spatial Fisheries Data (WGSFD), 8-12
June 2015, ICES Headquarters, Copenhagen, Denmark. ICES CM 2015/SSGEPI:18. 150pp
ICES 2016. Interim Report of the Working Group on Spatial Fisheries Data (WGSFD),
17-20 May 2016, Brest, France. ICES CM 2016/SSGEPI:18. 244 pp
Eigaard OR, Bastardie F, Breen M, et al. (2016) Estimating seabed pressure from
demersal trawls, seines, and dredges based on gear design and dimensions. ICES
Journal of Marine Science, 73:27-43
Church N.J., Carter A.J., Tobin D., Edwards D., Eassom A., Cameron A., Johnson
G.E., Robson, L.M. & Webb K.E. (2016) JNCC Recommended Pressure Mapping
Methodology 1. Abrasion: Methods paper for creating a geo-data layer for the
pressure 'Physical Damage (Reversible Change) - Penetration and/or disturbance
of the substrate below the surface of the seabed, including abrasion'. JNCC
report No. 515, JNCC, Peterborough
Development
-----------
sfdSAR is developed openly on
[GitHub](https://github.com/ices-tools-dev/sfdSAR).
Feel free to open an
[issue](https://github.com/ices-tools-dev/sfdSAR/issues) there if you
encounter problems or have suggestions for future versions.
## Example
The functions in this package are intended for one purpose: to compute the swept
area ratio (SAR) and the subsurface SAR of a fishing gear, which can then be
summarised over years and gear groupings.
Swept Area Ratio (SAR) is computed using the algorithm described below. The main
steps in the data processing are
1. Determine the gear width of the VMS record according to:
- Where average gear widths are supplied these are used.
- For VMS records with missing gear widths but that have supplied average
vessel characteristics (i.e. average overall vessel length or average KW
engine power): use the model described in (Eigaard et al., 2016) to
provide an estimate of gear width
- For VMS records with missing gear widths and missing vessel
characteristics use a fill-in value provided by ICES (2015) based on a
review by the JNCC or on the BENTHIS survey (Eigaard et al. 2016).
1. Estimate swept area based on gear type, fishing hours (hours), fishing speed
(speed) and gear width (width) for each record (ICES, 2016, p 69), note here
speed is in knots and requires to be converted to km per hour:
- Trawl : hours x width x speed x 1.82
- Danish seine : hours / 2.591234 x (width<sup>2</sup>) / (4 π)
- Scottish seine : hours / 1.9125 x (1.5 x width<sup>2</sup>) / (4 π)
1. Accumulate across gears for each year to produce annual totals of SA by
c-square and gear category, and finally average over years within gear
category and c-square.
1. Calculate SAR values by scaling by the area of the c-squares
The code below shows how the sfdSAR functions can be used to calculate swept
area ratio (SAR)
In the following examples the `dplyr` package is used to simplify the data
processing and a made up vms toy vms dataset (`test_vms`) will be used
```{r packages, echo=FALSE, message=FALSE, warning=FALSE}
library(dplyr)
library(sfdSAR)
data(test_vms)
```
```
library(dplyr)
library(sfdSAR)
## load sample vms data
data(test_vms)
```
### 1. Determine gear widths
The calculation of gear with is done using the data in the benthis model parameters table:
```{r gear_info, results="asis"}
library(icesVMS)
gear_widths <- get_benthis_parameters()
kableExtra::kable(gear_widths)
```
This table comes from Eigaard et al. (2016), with additions from ICES (2015).
And contains, for each benthis gear group, the proportion of the gear
contact that also affects the subsurface, the estimated average gear width,
and the coeffients and covariates of the surface contact model which relates
the gear width, properties of the vessel (kw or overall length) to
bottom contact.
In order to use this data a lookup table is required linking Metier level 6
codes to the benthis gear groupings listed above. The lookup table is given in
the `get_metier_lookup()` function from the `icesVMS` package and contains
other gear groupings used in ICES outputs and was initially developed by
ICES (2015).
```{r metier_lookup, results='asis'}
metier_lookup <- get_metier_lookup()
kableExtra::kable(head(metier_lookup))
```
Linking the gearwidths and contact model information is done with the following
two lines
```{r join}
# join widths and lookup
aux_lookup <-
gear_widths %>%
right_join(metier_lookup, by = c("benthisMet" = "benthisMetiers"))
# add aux data to vms
vms <-
aux_lookup %>%
right_join(test_vms, by = c("leMetLevel6" = "LE_MET_level6"))
```
and the gear width model is applied using the helper function `predict_gear_width`
```{r gearwidth}
# calculate the gear width model
vms$gearWidth_model <-
predict_gear_width(vms$gearModel, vms$gearCoefficient, vms)
```
In general, if gearwdth is available, it is used. If average overall vessel
length (oal) or average vessel power (kW) is available then the gear width
model is used. Finally if none of these are avaiable an average gear width is
applied. The following code implements this
```{r fillin}
# do the fillin for gear width:
# select provided average gear width, then modelled gear with, then benthis
# average if no kw or aol supplied
vms$gearWidth_filled <-
with(vms,
ifelse(!is.na(avg_gearWidth), avg_gearWidth / 1000,
ifelse(!is.na(gearWidth_model), gearWidth_model / 1000,
gearWidth)
))
```
### Predicting surface contact
finaly, surface contact is computed using the appropriate surface contact
model, given by the `contact_model` feild, defined as:
```{r contact_model}
sapply(unique(gear_widths$contactModel), function(x) body(get(x)))
```
The helper function `predict_surface_contact` computes the surface contact
(usage shown below). The feild `subsurface_prop` which has come from the
`gear_width` dataset can be used to compute subsurface contact from the surface
contact.
```{r surface}
# calculate surface contact
vms$surface <-
predict_surface_contact(vms$contactModel,
vms$fishingHours,
vms$gearWidth_filled,
vms$ICES_avg_fishing_speed)
# calculate subsurface contact
vms$subsurface <- vms$surface * as.numeric(vms$subsurfaceProp) * .01
```
### Summarising accross months etc.
Normally it is required to summarise the surface quantities, which can be done
like this
```{r summary}
# compute summaries of swept area over groups
sa <-
vms %>%
mutate(
mw_fishinghours = kw_fishinghours / 1000
) %>%
group_by(year, c_square, fishingCategoryFo) %>%
summarise(
mw_fishinghours = sum(mw_fishinghours, na.rm = TRUE),
subsurface = sum(subsurface, na.rm = TRUE),
surface = sum(surface, na.rm = TRUE)
) %>%
ungroup %>%
mutate(
lat = csquare_lat(c_square),
lon = csquare_lon(c_square)
)
```
```{r sa}
sa
```
### Computing Swept Area Ratio (SAR)
In the code below, SAR is calculated for each year, then averaged over years,
resulting in a dataset of averarage SAR per c_square. Note that, because
grouping is taking place over `c_square` the summation in the first
`group_by` section is equivalent to `sum(surface) / area`. The second grouping
section computes averages for each `c_square` over all years in the dataset.
```{r sar}
# compute swept area ratio per year and c_square then average over years
sar <-
sa %>%
mutate(
area = csquare_area(c_square)
) %>%
group_by(c_square, year) %>%
summarise(
surface_sar = sum(surface / area, na.rm = TRUE),
subsurface_sar = sum(subsurface / area, na.rm = TRUE)
) %>%
ungroup() %>%
group_by(c_square) %>%
summarise(
surface_sar = mean(surface_sar, na.rm = TRUE),
subsurface_sar = mean(subsurface_sar, na.rm = TRUE)
)
sar
```
### All in one
The steps described above are combined into one code block for convienience.
This code can be applied to a larger dataset to covering a range of years,
fishing gears and c_squares.
```{r ref.label=c("join", "gearwidth", "fillin", "surface", "summary", "sar")}
```
### Notes
This document was created using:
```{r, eval=FALSE}
rmarkdown::render("README.Rmd")
```