-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport5_VMS.R
93 lines (71 loc) · 2.53 KB
/
report5_VMS.R
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
library(icesTAF)
library(icesFO)
library(sf)
library(ggplot2)
library(dplyr)
## Run utilies
source("bootstrap/utilities.r")
# set values for automatic naming of files:
cap_year <- 2021
cap_month <- "November"
ecoreg_code <- "FO"
ecoreg <- "FO"
###########
##Load data
###########
# read vms fishing effort
effort <-
sf::st_read("vms_effort.csv",
options = "GEOM_POSSIBLE_NAMES=wkt", crs = 4326)
effort <- dplyr::select(effort, -WKT)
# read vms swept area ratio
sar <-
sf::st_read("vms_sar.csv",
options = "GEOM_POSSIBLE_NAMES=wkt", crs = 4326)
sar <- dplyr::select(sar, -WKT)
#set range of years in plots
year_range = "2017-2020" ## NEED TO CHECK THIS
###########
## 3: VMS #
###########
#~~~~~~~~~~~~~~~#
# A. Effort map
#~~~~~~~~~~~~~~~#
gears <- c("Static", "Midwater", "Otter", "Demersal seine")
effort <-
effort %>%
dplyr::filter(fishing_category_FO %in% gears) %>%
dplyr::mutate(
fishing_category_FO =
dplyr::recode(fishing_category_FO,
Static = "Static gears",
Midwater = "Pelagic trawls and seines",
Otter = "Bottom otter trawls",
`Demersal seine` = "Bottom seines"),
mw_fishinghours = as.numeric(mw_fishinghours)
) %>%
filter(!is.na(mw_fishinghours))
# write layer
write_layer <- function(dat, fname) {
sf::write_sf(dat, paste0("report/", fname, ".shp"))
files <- dir("report", pattern = fname, full = TRUE)
files <- files[tools::file_ext(files) != "png"]
zip(paste0("report/", fname, ".zip"), files, extras = "-j")
file.remove(files)
}
write_layer(effort, paste0(year_cap, "_", ecoreg,"_FO_VMS_effort"))
# save plot
plot_effort_map(effort, ecoregion) +
ggtitle(paste0("Average MW Fishing hours ", year_range))
ggplot2::ggsave(file_name(cap_year,ecoreg_code,"VMS_effort", ext = "png"), path = "report", width = 170, height = 200, units = "mm", dpi = 300)
#~~~~~~~~~~~~~~~#
# A. Swept area map
#~~~~~~~~~~~~~~~#
# write layer
write_layer(sar, paste0(year_cap, "_", ecoreg,"_FO_VMS_sar"))
plot_sar_map(sar, ecoregion, what = "surface") +
ggtitle(paste0("Average surface swept area ratio ",year_range))
ggplot2::ggsave(file_name(cap_year,ecoreg_code,"VMS_sarA", ext = "png"), path = "report", width = 170, height = 200, units = "mm", dpi = 300)
plot_sar_map(sar, ecoregion, what = "subsurface")+
ggtitle(paste0("Average subsurface swept area ratio ",year_range))
ggplot2::ggsave(file_name(cap_year,ecoreg_code,"VMS_sarB", ext = "png"), path = "report", width = 170, height = 200, units = "mm", dpi = 300)