Skip to content

Commit

Permalink
include report
Browse files Browse the repository at this point in the history
  • Loading branch information
david-beauchesne committed Mar 27, 2024
1 parent 6022bb9 commit 9bbe0f5
Show file tree
Hide file tree
Showing 22 changed files with 831 additions and 2,421 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ pof-stac-insileco*
figures/*
!figures/atlas/
!figures/webinar/
frontpage.svg
frontpage.svg
118 changes: 25 additions & 93 deletions R/fig_aoi.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,34 @@
#' @export

fig_aoi <- function() {
# ------------------------------------------------------------------------
# Graph principal
out <- here::here("figures","aoi")
chk_create(out)
png(
here::here(out, "aoi.png"),
res = param$figures$resolution,
width = param$figures$width,
height = param$figures$height,
units = "mm",
pointsize = param$figures$pointsize
)

# ------------------
aoi <- sf::st_read("data/aoi/aoi.gpkg", quiet = TRUE)
can <- sf::st_read("data/basemap/canada.gpkg", quiet = TRUE)
canada <- sf::st_read("data/basemap/canada_full.gpkg", quiet = TRUE)
usa <- sf::st_read("data/basemap/usa.gpkg", quiet = TRUE)

# ------------------
# Labels
labs <- c("Study area")
# out <- here::here("figures", "aoi")
# chk_create(out)
# png(
# here::here(out, "aoi.png"),
# res = param$figures$resolution,
# width = param$figures$width,
# height = param$figures$height,
# units = "mm",
# pointsize = param$figures$pointsize
# )

# ------------------
global_parameters()
bbox <- param$bbox

# ------------------
yGap <- 1
par(family = 'serif', mar = c(.5, .5, .5, .5))
graphicsutils::plot0(x = c(bbox$xmin, bbox$xmax), y = c(bbox$ymin-yGap, bbox$ymax-yGap))
aoi <- sf::st_read(here::here("project-data/aoi/aoi.gpkg"), quiet = TRUE)
can <- sf::st_read(here::here("project-data/basemap/canada_full.gpkg"), quiet = TRUE)
usa <- sf::st_read(here::here("project-data/basemap/usa.gpkg"), quiet = TRUE)
gl <- sf::st_read(here::here("project-data/basemap/greenland.gpkg"), quiet = TRUE)
bbox <- sf::st_bbox(aoi)
par(family = "serif", mar = c(.5, .5, .5, .5))
graphicsutils::plot0(x = c(bbox$xmin, bbox$xmax), y = c(bbox$ymin, bbox$ymax))
plot(
sf::st_geometry(aoi),
lwd = 2,
border = param$col$aoi,
col = glue::glue("{param$col$focus}33"),
sf::st_geometry(aoi),
lwd = 2,
border = "#000000BB",
col = "#376e7d88",
add = TRUE
)
plot(sf::st_geometry(can), lwd = .5, col = param$col$coastline, add = TRUE)
plot(sf::st_geometry(usa), lwd = .5, col = param$col$coastline, add = TRUE)
plot(sf::st_geometry(can), lwd = .5, col = "#00000088", add = TRUE)
plot(sf::st_geometry(usa), lwd = .5, col = "#00000088", add = TRUE)
plot(sf::st_geometry(gl), lwd = .5, col = "#00000088", add = TRUE)
box()

# ------------------
# Text
rect(
bbox$xmin-.15,
bbox$ymax+.25-yGap,
bbox$xmin+2.8,
bbox$ymax-.275-yGap,
col = "#ffffffBB",
border = "#000000"
)
text(
x = bbox$xmin,
y = bbox$ymax-yGap,
labels = labs[1],
font = 2,
adj = c(0,.5),
cex = .8
)


#
# # ------------------
# # Cities
# plot(st_geometry(cities), add = TRUE, pch = 21, col = "#3e3e3e", bg = "#9f9f9f", cex = .4)
# for(i in 1:nrow(cities)) {
# text(x = cities$X[i]+cities$offX[i],
# y = cities$Y[i]+cities$offY[i],
# labels = cities$city[i],
# cex = .35,
# col = "#000000",
# adj = c(cities$adjX[i], .5))
# }
#
# # ---------------------------
# # Grille
# par(new = TRUE)
# par(fig = c(.035,.25,.6,.825), mar = c(0,0,0,0))
# # par(fig = c(.765,.965,.05,.25), mar = c(0,0,0,0))
# plot0(x = c(lacstpierre$xmin, lacstpierre$xmax), y = c(lacstpierre$ymin, lacstpierre$ymax))
# box(col = "#00000088")
# plotDat(trans = "FF")
# text(x = lacstpierre$xmin + 750, y = lacstpierre$ymax - 3000, labels = labs[4], cex = .5, font = 3, adj = c(0,.5))
#
# ---------------------------
# Canada
par(new = TRUE)
par(fig = c(.6,.965,.039,.36), mar = c(0,0,0,0))
bbox <- sf::st_bbox(canada)
graphicsutils::plot0(x = c(bbox$xmin, bbox$xmax), y = c(bbox$ymin, bbox$ymax))
plot(sf::st_geometry(canada), col = glue::glue("{param$col$coastline}33"), add = TRUE)
plot(sf::st_geometry(usa), col = glue::glue("{param$col$coastline}33"), add = TRUE)
plot(sf::st_geometry(aoi),lwd = 1, border = param$col$focus,col = param$col$focus, add = TRUE)
box(col = "#000000")

# ---------------------------
dev.off()
# dev.off()
}
11 changes: 11 additions & 0 deletions R/threat_pollution.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ threat_pollution <- function() {

# Remove downloaded data
# fs::dir_delete(tmp)

# Export partial data for use in report (this should be revisited)
out <- here::here("project-data", "partials")
pipedat::chk_create(out)
pipedat::masterwrite(neec, here::here(out, "neec"))
# ----------------------------------------------------------------
# To explore:
# Impact to Waterbody field. Consider if we should treat “actual” vs. “potential” spills differently. Data on “potential” spills only started being recorded in April 2021 onward (no differentiation before that). Some “Potential” spills may report very large amounts of substance that was not actually spilled (e.g. Incident Number NL-20200611-03045-20 was a disabled vessel with 400000 L of fuel on board, but nothing spilled). These “Potential” spills still represent risk even if no true pollution occurred.
Expand All @@ -93,6 +98,9 @@ threat_pollution <- function() {
dplyr::filter(!is.na(volume_l)) |>
dplyr::rename(geometry = geom)

# Export partial data for use in report (this should be revisited)
pipedat::masterwrite(nasp, here::here(out, "nasp"))

# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
# ISTOP data
# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
Expand All @@ -108,6 +116,9 @@ threat_pollution <- function() {
area = as.numeric(area)
)

# Export partial data for use in report (this should be revisited)
pipedat::masterwrite(istop, here::here(out, "istop"))

# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
# Threat layer - diffusive model
# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
Expand Down
106 changes: 94 additions & 12 deletions docs/report/1_shipping.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.4.543">
<meta name="generator" content="quarto-1.4.551">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

Expand All @@ -20,7 +20,27 @@
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
</style>
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 1em;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>


<script src="site_libs/quarto-nav/quarto-nav.js"></script>
Expand Down Expand Up @@ -123,20 +143,23 @@
<a href="./2_petroleum.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Petroleum pollution based on past incidents</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./3_references.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">References</span></span></a>
</div>
</li>
</ul>
</div>
</nav>
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">

<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>

<ul>
<li><a href="#tasks" id="toc-tasks" class="nav-link active" data-scroll-target="#tasks"><span class="header-section-number">2.1</span> Tasks</a></li>
<li><a href="#global-fishing-watch" id="toc-global-fishing-watch" class="nav-link" data-scroll-target="#global-fishing-watch"><span class="header-section-number">2.2</span> Global Fishing Watch</a></li>
<li><a href="#vessel-density-mapping" id="toc-vessel-density-mapping" class="nav-link" data-scroll-target="#vessel-density-mapping"><span class="header-section-number">2.3</span> Vessel Density Mapping</a></li>
<li><a href="#notes-references" id="toc-notes-references" class="nav-link" data-scroll-target="#notes-references"><span class="header-section-number">2.4</span> Notes &amp; references</a></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
Expand All @@ -160,8 +183,45 @@ <h1 class="title"><span class="chapter-number">2</span>&nbsp; <span class="chapt
</header>


<section id="tasks" class="level2" data-number="2.1">
<h2 data-number="2.1" class="anchored" data-anchor-id="tasks"><span class="header-section-number">2.1</span> Tasks</h2>
<ol type="1">
<li>Access to shipping AIS data through Global Fishing Watch</li>
<li>Prepare monthly petroleum pollution and disturbance due to vessel traffic threat layers in the Atlantic Ocean
<ol type="1">
<li>All vessels</li>
<li>Cargo/bulk vessels</li>
<li>Fishing vessels</li>
</ol></li>
</ol>
</section>
<section id="global-fishing-watch" class="level2" data-number="2.2">
<h2 data-number="2.2" class="anchored" data-anchor-id="global-fishing-watch"><span class="header-section-number">2.2</span> Global Fishing Watch</h2>
<p>The purpose of Global Fishing Watch is to create and publicly share knowledge about human activity at sea to enable fair and sustainable use of our ocean. They use cutting-edge technology to turn big data into actionable information. They believe human activity at sea should be common knowledge in order to safeguard the global ocean for the good of all. Global Fishing Watch’s open-access technology products, datasets, and code accelerate research and innovation and support sustainable ocean management. They offer a variety of products related to human activity at sea, including shipping and fisheries, but also data on ocean conditions and biology. Access to their data can be achieved through their <a href="https://globalfishingwatch.org/our-apis/">API</a>, which is also accessible through an R Package called <a href="https://github.com/GlobalFishingWatch/gfwr"><code>gfwr</code></a>.</p>
<p>The <code>gfwr</code> R package offers wrapper functions to access data through the GFW APIs. It provides convenient functions to freely pull GFW data directly into R in tidy formats. The package currently works with the following APIs:</p>
<ul>
<li><a href="https://globalfishingwatch.org/our-apis/documentation#vessels-api">Vessels API</a>: vessel search and identity based on AIS self-reported data</li>
<li><a href="https://globalfishingwatch.org/our-apis/documentation#events-api">Events API</a>: encounters, loitering, port visits and fishing events based on AIS data</li>
<li><a href="https://globalfishingwatch.org/our-apis/documentation#map-visualization-4wings-api">Map Visualization (4Wings API</a>: apparent fishing effort based on AIS data</li>
</ul>
<p>The incentive of fetching data from such an API is that the current project could have been built so that continuous integration of new data could be performed, ensuring an updated assessment of this particular threat layer through time. However, after exploring the APIs and contacting representatives of GFW, we had to come to the conclusion that the data needed for this project were not and would likely not be available through their API. They stated that other products that might be useful are planned to be released in the future, such as vessel presence raster resources. However, the release dates for these resources extends beyond the timelines of the current project. We therefore had to pivot to an alternative data source to complete this part of the contract.</p>
</section>
<section id="vessel-density-mapping" class="level2" data-number="2.3">
<h2 data-number="2.3" class="anchored" data-anchor-id="vessel-density-mapping"><span class="header-section-number">2.3</span> Vessel Density Mapping</h2>
<p>During the same timeframe of this project, <span class="citation" data-cites="veinot2023">Veinot et al. (<a href="#ref-veinot2023" role="doc-biblioref">2023</a>)</span> published a Technical Report detailing a project seeking to map vessel density in the Northwest Atlantic in 2019 using Automatic Identification System (AIS) data. Their work covers our study area, but was not available publicly yet. Since, their work has been extended to include vessel density mapping for the years 2013 through 2022 and has been made public on the Open Government data platform as a series entitled <a href="https://open.canada.ca/data/en/dataset/e60a7e32-5a67-45d6-900d-e6ab6b581a51"><em>Vessel Density Mapping Series in the Northwest Atlantic</em></a>. These data provide vessel density raster layers monthly for all vessel types combined, and yearly for different vessel types. This does not match perfectly with the requirements for this project. Namely, we would need to differentiate between daytime and nighttime vessel traffic, and use monthly data for each vessel type. In light of this, we agreed on a strategy to address this issue.</p>
<p>First, we built the code necessary to access the openly available data and integrate it in our study grid.; this data serves as an acceptable backup plan in case we cannot access more detailed data. The <a href="https://github.com/inSilecoInc/ceacws/blob/main/project-data/pipedat/vessel_density_mapping_dfo-98916b4a/vessel_density_mapping_dfo-98916b4a.R">code</a> that fetches the data from the Open Government platform and integrates it in our study grid has therefore been developed and is available in the <em>research compendium</em>.</p>
<p>Second, the team from the CWS contacted the authors of <span class="citation" data-cites="veinot2023">Veinot et al. (<a href="#ref-veinot2023" role="doc-biblioref">2023</a>)</span> to discuss the possibility of either accessing the raw AIS data that they used to generate their own vessel density mapping, collaborating on a refined version of their work that addresses the needs of the CWS, or a combination of both. After discussing with their team, it was agreed that we would meet with a representative from their team to discuss the approach that they used to prepare their vessel density layers and potentially collaborate on updating their code to generate the layers that are required for this project. It was also agreed that the Northwest Atlantic region track lines and AIS data points, with MMSI data and times could be shared with us, under condition of a signed agreement and the transfer of anonymized MMSI numbers to ensure confidentiality. The data were transferred to the CWS on March 20th and we are currently waiting to have access to continue with our work. The threat layers using shipping data will therefore be completed during the second part of this project.</p>
</section>
<section id="notes-references" class="level2" data-number="2.4">
<h2 data-number="2.4" class="anchored" data-anchor-id="notes-references"><span class="header-section-number">2.4</span> Notes &amp; references</h2>


<div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="1" data-line-spacing="5" role="list">
<div id="ref-veinot2023" class="csl-entry" role="listitem">
Veinot, T., Nicoll, A., Rozalska, K., and Coffen-Smout, S. (2023). Vessel <span>Density Mapping</span> of 2019 <span>Automatic Identification System</span> (<span>AIS</span>) <span>Data</span> in the <span>Northwest Atlantic</span>. <span>Can</span>. <span>Tech</span>. <span>Rep</span>. <span>Fish</span>. <span>Aquat</span>. <span>Sci</span>. 3520: Vi + 29 p. <span>Department of Fisheries and Oceans</span>.
</div>
</div>
</section>

</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
Expand Down Expand Up @@ -243,6 +303,24 @@ <h1 class="title"><span class="chapter-number">2</span>&nbsp; <span class="chapt
// clear code selection
e.clearSelection();
});
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
var mailtoRegex = new RegExp(/^mailto:/);
var filterRegex = new RegExp('/' + window.location.host + '/');
var isInternal = (href) => {
return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
}
// Inspect non-navigation links and adorn them if external
var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool)');
for (var i=0; i<links.length; i++) {
const link = links[i];
if (!isInternal(link.href)) {
// undo the damage that might have been done by quarto-nav.js in the case of
// links that we want to consider external
if (link.dataset.originalHref !== undefined) {
link.href = link.dataset.originalHref;
}
}
}
function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
const config = {
allowHTML: true,
Expand Down Expand Up @@ -277,7 +355,11 @@ <h1 class="title"><span class="chapter-number">2</span>&nbsp; <span class="chapt
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
if (note) {
return note.innerHTML;
} else {
return "";
}
});
}
const xrefs = window.document.querySelectorAll('a.quarto-xref');
Expand Down Expand Up @@ -553,12 +635,12 @@ <h1 class="title"><span class="chapter-number">2</span>&nbsp; <span class="chapt
</script>
<nav class="page-navigation">
<div class="nav-page nav-page-previous">
<a href="./index.html" class="pagination-link aria-label=" &lt;span="">
<a href="./index.html" class="pagination-link" aria-label="Introduction">
<i class="bi bi-arrow-left-short"></i> <span class="nav-page-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Introduction</span></span>
</a>
</div>
<div class="nav-page nav-page-next">
<a href="./2_petroleum.html" class="pagination-link" aria-label="<span class='chapter-number'>3</span>&nbsp; <span class='chapter-title'>Petroleum pollution based on past incidents</span>">
<a href="./2_petroleum.html" class="pagination-link" aria-label="Petroleum pollution based on past incidents">
<span class="nav-page-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Petroleum pollution based on past incidents</span></span> <i class="bi bi-arrow-right-short"></i>
</a>
</div>
Expand Down
Loading

0 comments on commit 9bbe0f5

Please sign in to comment.