-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
209 lines (144 loc) · 10.7 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
#for cropping whitespace from around figures, use crop = TRUE
knitr::knit_hooks$set(crop = knitr::hook_pdfcrop)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.align = "center",
fig.width = 7,
fig.height = 5,
crop = TRUE
)
devtools::load_all()
```
# oceandatr <a href="https://emlab-ucsb.github.io/oceandatr/"><img src="man/figures/logo.png" align="right" height="139" alt="oceandatr website" /></a>
<!-- badges: start -->
<!-- badges: end -->
`oceandatr` aims to provide simple functions for retrieving ocean data. Using the associated package `spatialgridr`, it can also easily grid data, which is useful for various purposes including spatial conservation prioritization.
Fish images in logo modified from original by Tracey Saxby, [Integration and Application Network](https://ian.umces.edu/media-library)
## Installation
You can install oceandatr from [GitHub](https://github.com/) with:
```{r, eval = FALSE}
if (!require(remotes)) install.packages("remotes")
#might need to increase timeout as it is a large package
options(timeout = 9999)
remotes::install_github("emlab-ucsb/oceandatr")
```
# Getting gridded ocean data
```{r eval=FALSE}
#load oceandatr package
library(oceandatr)
```
### Obtain an EEZ for an area of interest
First we need a boundary for the area we are interested in. We can use the `get_boundary()` function, imported from `spatialgridr`, to get a boundary for land or ocean. In this example we will get Bermuda's Exclusive Economic Zone (EEZ)
```{r area_of_interest}
bermuda_eez <- get_boundary(name = "Bermuda")
#plot to check we have Bermuda's EEZ
plot(bermuda_eez[1], col = "lightblue", main=NULL, axes=TRUE)
```
## Get a grid
We are going to get gridded data. To create a grid for Bermuda, we use `get_grid()`. We need to provide a suitable projection for the area we are interested in, https://projectionwizard.org is useful for this purpose. Standard projections used for countries can also be found at https://epsg.io/ by searching with country name. For spatial planning, equal area projections are normally best.
The bounding box coordinates for the area of interest can be found using `sf::st_bbox(bermuda_eez)` and these can then be used to generate the coordinate reference system (CRS) on [projection wizard](https://projectionwizard.org)
The coordinates above should be entered as the 'Geographic extent' and the map should then have a box drawn around the bounding box of the area of interest. The projection can then be copied and pasted from the pop-up box when clicking on 'WKT' or 'PROJ'. For brevity, we are using the PROJ string, but WKT is now [generally preferred](https://inbo.github.io/tutorials/tutorials/spatial_crs_coding/). The projection needs to be placed in quotation marks as follows:
```{r projection}
projection_bermuda <- '+proj=laea +lon_0=-64.8108333 +lat_0=32.3571917 +datum=WGS84 +units=m +no_defs'
```
We can now create a grid for Bermuda's EEZ using `get_grid()`. Along with the projection we found above, we will need to set a resolution: how wide and high will each grid cell be, in this case in metres. The units will depend on your crs and can be found using e.g. `sf::st_crs(projection_bermuda, parameters = TRUE)$units_gdal`
```{r bermuda-grid, warning=FALSE}
bermuda_grid <- get_grid(boundary = bermuda_eez, resolution = 5000, crs = projection_bermuda)
#project the eez into same projection as grid for plotting
bermuda_eez_projected <- bermuda_eez %>%
sf::st_transform(crs = projection_bermuda) %>%
sf::st_geometry()
#plot the grid
terra::plot(bermuda_grid, col = "gold3", axes = FALSE, legend = FALSE)
plot(bermuda_eez_projected, add=TRUE)
```
The raster covers Bermuda's EEZ. The grid cells would be too small to see if we plotted them, but here is a coarser grid (lower resolution) visualized so we can see what the grid cells look like.
```{r grid_cells}
bermuda_grid_coarse <- get_grid(boundary = bermuda_eez, resolution = 20000, crs = projection_bermuda)
plot(bermuda_eez_projected, axes = FALSE)
terra::plot(terra::as.polygons(bermuda_grid_coarse, dissolve = FALSE), add=TRUE)
```
## Get bathymetry
Now we have a grid, we can get some data. A key piece of data is bathymetry. If the user has bathymetry data for their area of interest already, they can pass the file path to this function and it will grid the data using the supplied spatial grid. If no file path is provided, the function will extract bathymetry data for the area from the [ETOPO 2022 Global Relief model](https://www.ncei.noaa.gov/products/etopo-global-relief-model) using a function borrowed from the [`marmap`](https://cran.r-project.org/web/packages/marmap/index.html) package.
```{r bathymetry}
bathymetry <- get_bathymetry(spatial_grid = bermuda_grid, classify_bathymetry = FALSE)
terra::plot(bathymetry, col = hcl.colors(n=255, "Blues"), axes = FALSE)
plot(bermuda_eez_projected, add=TRUE)
```
### Depth classification
The ocean can be classified into 5 depth zones:
* 0 - 200m: Epipelagic zone
* 200 - 1000m: Mesopelagic zone
* 1000 - 4000m: Bathypelagic zone
* 4000 - 6000m: Abyssopelagic zone
* 6000m+: Hadopelagic zone
We can get the depth zones for Bermuda simply by setting the `classify_bathymetry` argument in `get_bathymetry` to `TRUE`.
```{r depth_classification}
depth_zones <- get_bathymetry(spatial_grid = bermuda_grid, classify_bathymetry = TRUE)
#value of 1 indicates that depth zone is present
terra::plot(depth_zones, col = c("grey60", "navyblue"), axes = FALSE, fun = function(){terra::lines(terra::vect(bermuda_eez_projected))})
```
## Get geomorphological data
The seafloor has its own valleys, plains and other geomorphological features just as on land. These data come from [Harris et al. 2014, Geomorphology of the Oceans](https://doi.org/10.1016/j.margeo.2014.01.011) and are available for download from https://www.bluehabitats.org, but all but depth classifications (which can be created using `get_bathymetry()`) and seamounts (which can be retrieved from a more recent dataset using `get_seamounts()`) are included in this package.
```{r geomorphology, warning=FALSE, message=FALSE}
geomorphology <- get_geomorphology(spatial_grid = bermuda_grid) %>%
remove_empty_layers() #can remove any empty layers so we don't have so many layers to plot
#brown colour indicates that geomorphological feature is present
terra::plot(geomorphology, col = data.frame(c(0,1), c("grey60", "sienna")), axes = FALSE, legend = FALSE, fun = function(){terra::lines(terra::vect(bermuda_eez_projected))})
```
## Get knolls data
Knolls are another geomorphological feature, which are 'small' seamounts, classified as seamounts between 200 and 1000m higher than the surrounding seafloor [Morato et al. 2008](https://doi.org/10.3354/meps07268). Data are the knoll base area data from [Yesson et al. 2011]( https://doi.org/10.1016/j.dsr.2011.02.004).
```{r knolls, warning=FALSE, message=FALSE}
knolls <- get_knolls(spatial_grid = bermuda_grid)
#value of 1 indicates that knolls are present
terra::plot(knolls, col = c("grey60", "grey20"), axes = FALSE)
plot(bermuda_eez_projected, add=TRUE)
```
## Get seamount areas
Seamounts, classified as peaks at least 1000m higher than the surrounding seafloor [Morato et al. 2008](https://doi.org/10.3354/meps07268). These data are from [Yesson et al. 2021](https://doi.org/10.14324/111.444/ucloe.000030). Each peak is buffered to the distance specified in the function call. The units of the buffer are in the same units as the spatial grid, which can be checked using, e.g. `sf::st_crs(bermuda_grid, parameters = TRUE)$units_gdal`
```{r seamounts, warning=FALSE, message=FALSE}
#spatial grid units are metres, so set buffer to 30000 m = 30 km
seamounts <- get_seamounts(spatial_grid = bermuda_grid, buffer = 30000)
#value of 1 indicates that seamount is present
terra::plot(seamounts, col = c( "grey60", "saddlebrown"), axes = FALSE)
plot(bermuda_eez_projected, add=TRUE)
```
## Habitat suitability models
Retrieve habitat suitability data for 3 deep water coral groups:
* Antipatharia: Habitats associated with increased biodiversity in both invertebrate and vertebrate species; global distributions were modeled by [Yesson et al. (2017)](https://doi.org/10.1016/j.dsr2.2015.12.004)
* Cold water coral: Important habitats and nursery areas for many species; global distributions were modeled by [Davies and Guinotte (2011)](https://doi.org/10.1371/journal.pone.0018483)
* Octocoral: Important habitats for invertebrates, groundfish, rockfish and other species; global distributions were modeled by [Yesson et al. (2012)](https://doi.org/10.1111/j.1365-2699.2011.02681.x)
```{r coral_habitat, warning=FALSE, message=FALSE}
coral_habitat <- get_coral_habitat(spatial_grid = bermuda_grid)
#show the seamounts areas on the plot: coral habitat is often on seamounts which are shallower than surrounding ocean floor
#value of 1 indicates that coral is present
terra::plot(coral_habitat, col = c("grey60", "coral"), axes = FALSE, fun = function()terra::lines(terra::as.polygons(seamounts, dissolve = TRUE), col = "orangered4"))
```
## Environmental Regions
Bioregions are often included in spatial planning, but available bioregional classifications are either too coarse or too detailed to be useful for planning at the EEZ level. Borrowing methods from [Magris et al. 2020](https://doi.org/10.1111/ddi.13183), we use spatial clustering of biophysical environmental data from [Bio-Oracle](https://bio-oracle.org/), to create 'environmental regions'. Biophysical conditions within a environmental region are more similar than areas outside that region, though the differences may be small. Diagnostic boxplots and a PCA will be shown if `show_plots = TRUE`. All the biophysical data are ocean surface data for the period 2010 - 2020:
* Chlorophyll concentration (mean, mg/ m3)
* Dissolved oxygen concentration (mean)
* Nitrate concentration (mean, mmol/ m3)
* pH (mean)
* Phosphate concentration (mean, mmol/ m3)
* total Phytoplankton (primary productivity; mean, mmol/ m3)
* Salinity (mean)
* Sea surface temperature (max, degree C)
* Sea surface temperature (mean, degree C)
* Sea surface temperature (min, degree C)
* Silicate concentration (mean, mmol/ m3)
```{r environmental_regions, warning=FALSE, message=FALSE}
#set number of clusters to 3 to reduce runtime and memory usage
enviro_regions <- get_enviro_regions(spatial_grid = bermuda_grid, show_plots = TRUE, num_clusters = 3)
```
```{r enviro_regions_maps, warning=FALSE, message=FALSE}
#value of 1 indicates that environmental region is present
terra::plot(enviro_regions, col = c("grey60", "forestgreen"), axes = FALSE, fun = function(){terra::lines(terra::vect(bermuda_eez_projected))})
```