oceandatr

Aims to provide simple functions for creating data for conducting a spatial conservation prioritization for large scale areas of the ocean, specifically offshore areas.
https://github.com/emlab-ucsb/oceandatr

Category: Biosphere
Sub Category: Conservation and Restoration

Last synced: about 6 hours ago
JSON representation

Repository metadata

Offshore data preparation for prioritization package

README.Rmd

          ---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "1%"
)
devtools::load_all()

#figure output settings
h = 6
w = 6
ow = "600"
```

# oceandatr oceandatr website




`oceandatr` aims to provide simple functions for creating data for conducting a spatial conservation prioritization for large scale areas of the ocean, specifically offshore areas.

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")
```

## Example of usage

```{r eval=FALSE}
#load oceandatr package
library(oceandatr)
```

### Obtain an EEZ for an area of interest

This function pulls data for EEZs from the [Marine Gazetteer](https://marineregions.org/gazetteer.php) using the `mregions2` R package; the function is just a wrapper to make the process a bit simpler. 

```{r area of interest, fig.height=h, fig.width=w, out.width=ow}
bermuda_eez <- get_area(area_name = "Bermuda", mregions_column = "territory1")

#plot to check we have Bermuda's EEZ
plot(bermuda_eez[1], col = "lightblue", main=NULL, axes=TRUE)
```

# Choose a CRS

Best practice is to use a local, equal area projection for all geospatial data for use in the prioritization. Finding a suitable projection can be tricky, but [projection wizard](https://projectionwizard.org) provides a handy tool. Standard projections used for countries can also be found at https://epsg.io/ by searching with country name. 

The bounding box coordinates for the area of interest can be used to generate the coordinate reference system (CRS) on [projection wizard](https://projectionwizard.org)

```{r}
sf::st_bbox(bermuda_eez)
```

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'
```


### Get a planning grid for the area of interest

A planning grid is needed for spatial prioritization. This divides the area of interest into grid cells. The `get_grid` function will return a planning grid for the specified area of interest (polygon), projected into the coordinate reference system specified, at the cell resolution specified in kilometres.

```{r planning grid, warning=FALSE, fig.height=h, fig.width=w, out.width=ow}
planning_grid <- get_grid(area_polygon = bermuda_eez, projection_crs = projection_bermuda, resolution = 5000)

#project the eez into same projection as planning grid for plotting
bermuda_eez_projected <- bermuda_eez %>% 
  sf::st_transform(crs = projection_bermuda) %>% 
  sf::st_geometry()

#plot the planning grid
terra::plot(planning_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 planning grid cells, fig.height=h, fig.width=w, out.width=ow}
planning_grid_coarse <- get_grid(area_polygon = bermuda_eez, projection_crs = projection_bermuda, resolution = 20000)

plot(bermuda_eez_projected, axes = FALSE)
terra::plot(terra::as.polygons(planning_grid_coarse, dissolve = FALSE), add=TRUE)
```

### Get bathymetry

Now we have our planning grid, we can get data for this area of interest. A key piece of data is bathymetry. If the user has downloaded data for the area of interest from the [GEBCO website](https://www.gebco.net), they can pass the file path to this function and it will crop and rasterize the data using the supplied planning 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` package.

```{r bathymetry, fig.height=h, fig.width=w, out.width=ow}
bathymetry <- get_bathymetry(spatial_grid = planning_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, fig.height=h, fig.width=w, out.width=ow}
depth_zones <- get_bathymetry(spatial_grid = planning_grid, classify_bathymetry = TRUE)

terra::plot(depth_zones, col = "navyblue", axes = FALSE, legend = FALSE, fun = function(){terra::lines(terra::vect(bermuda_eez_projected))})
```

### Get geomorphological data

The seafloor has its own mountains, 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. The features that are suggested as major habitats for inclusion in no-take MPAs by [Ceccarelli et al. 2021](https://doi.org/10.3389/fmars.2021.634574) are included in this package, so it is not necessary to download them.

```{r geomorphology, warning=FALSE, message=FALSE, fig.height=h, fig.width=w, out.width=ow}
geomorphology <- get_geomorphology(spatial_grid = planning_grid)

terra::plot(geomorphology, col = "sienna2", 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, fig.height=h, fig.width=w, out.width=ow}
knolls <- get_knolls(spatial_grid = planning_grid)

terra::plot(knolls, col = "grey40", axes = FALSE, legend = 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 area polygon or planning grid, which can be checked using, e.g. `sf::st_crs(planning_grid, parameters = TRUE)$units_gdal`

```{r seamounts, warning=FALSE, message=FALSE, fig.height=h, fig.width=w, out.width=ow}
#planning grid units are metres, so set buffer to 30000 m = 30 km
seamounts <- get_seamounts_buffered(spatial_grid = planning_grid, buffer = 30000)

terra::plot(seamounts, col = "saddlebrown", axes = FALSE, legend = 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, fig.height=h, fig.width=w, out.width=ow}
coral_habitat <- get_coral_habitat(spatial_grid = planning_grid)

#show the seamounts areas on the plot: coral habitat is often on seamounts which are shallower than surrounding ocean floor
plot_add <- function(){
  terra::lines(terra::vect(bermuda_eez_projected), col = "grey40")
  terra::lines(terra::as.polygons(seamounts, dissolve = TRUE), col = "orangered4")
  }

terra::plot(coral_habitat, col = "coral", axes = FALSE, fun = plot_add)
```

## 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)

```{r environmental regions, warning=FALSE, message=FALSE, fig.height=h, fig.width=w, out.width=ow}
#cluster the data
#set number of clusters to 3 to reduce runtime and memory usage
enviro_regions <- get_enviro_regions(spatial_grid = planning_grid, num_clusters = 3)
```


```{r, warning=FALSE, message=FALSE, fig.height=h, fig.width=w, out.width=ow}
#plot
terra::plot(enviro_regions, col = "forestgreen", axes = FALSE, legend =FALSE, fun = function(){terra::lines(terra::vect(bermuda_eez_projected))})
```


```{r pressure, echo = FALSE, include=FALSE}
## REMINDER FOR ME, WILL DELETE:

# You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. You could also use GitHub Actions to re-render `README.Rmd` every time you push. An example workflow can be found here: .
# 
# You can also embed plots, for example:

#plot(pressure)

#In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN.
```



        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 8 days ago

Total Commits: 246
Total Committers: 3
Avg Commits per committer: 82.0
Development Distribution Score (DDS): 0.354

Commits in past year: 84
Committers in past year: 2
Avg Commits per committer in past year: 42.0
Development Distribution Score (DDS) in past year: 0.024

Name Email Commits
Jason Flower j****t@a****m 159
Echelle Burns e****s@g****m 86
Jason Everett j****t@g****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 62
Total pull requests: 11
Average time to close issues: 2 months
Average time to close pull requests: about 2 hours
Total issue authors: 4
Total pull request authors: 2
Average comments per issue: 1.81
Average comments per pull request: 0.0
Merged pull request: 10
Bot issues: 0
Bot pull requests: 0

Past year issues: 11
Past year pull requests: 7
Past year average time to close issues: 4 months
Past year average time to close pull requests: about 2 hours
Past year issue authors: 3
Past year pull request authors: 1
Past year average comments per issue: 0.27
Past year average comments per pull request: 0.0
Past year merged pull request: 7
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/emlab-ucsb/oceandatr

Top Issue Authors

  • jflowernet (29)
  • echelleburns (28)
  • jaseeverett (4)
  • jeffreyhanson (1)

Top Pull Request Authors

  • jflowernet (9)
  • jaseeverett (2)

Top Issue Labels

  • documentation (10)
  • bug (5)
  • enhancement (5)
  • good first issue (2)

Top Pull Request Labels


Dependencies

DESCRIPTION cran
  • R >= 2.10 depends
  • dplyr * imports
  • exactextractr * imports
  • magrittr * imports
  • mregions2 * imports
  • sf * imports
  • terra * imports
  • tidyr * imports
  • testthat >= 3.0.0 suggests

Score: 3.8066624897703196