ocean3d

ocean3d is an R package for three-dimensional marine spatial analysis of species ranges, fisheries, and depth-stratified oceanographic data. It grew out of work on sharks, rays, and chimaeras, with the functions generalising to any marine taxon or spatial layer.

The three-dimensional marine environment poses a unique challenge for spatial analyses. Most conventional GIS workflows represent space as a two-dimensional plane. This abstraction fails to capture the range of depths and vertical overlap of marine habitat. Fisheries also operate at different depths depending on gear type and target species, creating depth-specific patterns of threat exposure that require analysis in 3D volume rather than 2D planes to quantify. ocean3d provides documented workflows and reusable functions for:

How it works

In order to represent the 3D space in the ocean, we use a stacked-raster approach built on terra. We call this the Spatial Voxel Model, with the class SpatVoxel. Using this SpatVoxel, we can represent any number of spatial phenomena in the ocean, including species distributions, fishing effort, and oceanographic variables.

Diagram that represents the multi-depth spatial voxel model

This package includes functions for converting common vector representations to the SpatVoxel class 3D representation. One example operation enabled by ocean3d is to take an existing vector and observed depth range, and have it match with a pre-existing SpatVoxel.

Converting species range vector into SpatVoxel

ocean3d uses two representations for 3D geometry: A SpatEnvelope stores one continuous [depth_min, depth_max] interval per cell; a SpatVoxel (shown above) stores a value at each of a set of depth levels, so it can hold a variable and interior gaps. SpatEnvelope is useful for representing discrete 3D geometry (ex. species ranges with defined boundaries for area and depth). In contrast, SpatVoxel is ideal for representing continuous values (ex. species distribution models with probabilities of occurrence, rather than presence and absences). SpatVoxel can also represent overhangs, holes, etc. in 3D space since it contains a value for every depth, rather than a depth range.

This package includes utilities for working with commonly used datasets in marine habitat spatial analyses, including IUCN Red List, World Ocean Atlas, GEBCO, Copernicus Marine, and Global Fishing Watch.

Installation

You can install the development version of ocean3d from GitHub with:

# install.packages("devtools")
devtools::install_github("Marine-Biodiversity-Conservation-Lab/ocean3d")

Learning resources

New to ocean3d? Watch the recording of the EEA 2026 workshop, which walks through the package and its main workflows:

EEA 2026 workshop recording

Function overview

Create a raster covering extent of multiple spatial inputs

3D representations

Conversion between 3D representations

3D spatial query

Three functions ask how a SpatEnvelope or SpatVoxel relates to another object in 3D. The other object can be a 3D object or a 2D one: a SpatRaster footprint or polygons (SpatVector, sf). A 2D object restricts the domain horizontally and without restricting the depths.

3D volume

Both dispatch on the 3D representation, so they take either a SpatEnvelope or a SpatVoxel. A voxel’s volume sums the slab each occupied depth level stands for, so interior gaps cost volume instead of being filled in. Given one of each, the envelope is discretized onto the voxel’s depth levels.

Environmental extraction to areas

See vignette("ocean3d") for the full workflow, from a range polygon through to a vertical profile of the values inside it.

Environmental extraction to point observations

Common spatial dataset utilities

IUCN Red List API utilities

Add an IUCN Red List API key to access species-assessment functions. Sign up and acquire your API key at https://api.iucnredlist.org/:

usethis::edit_r_environ()
# Add the following line to the .Renviron file
# IUCN_REDLIST_KEY="your_iucn_api_key_here"

GEBCO Bathymetry

World Ocean Atlas 2023 utilities

Global Fishing Watch (fisheries effort)

Contributing

Contributions are welcome. ocean3d is being actively built out from a set of lab analyses into a general, tested package, and there is plenty of well-scoped work available. Start with:

New contributors: the "Known rough edges / good first issues" section of CONTRIBUTING.md lists concrete starting points.

Acknowledgements

Thank you to the people that have inspired and collaborated on this work!

David Ruiz-García, Rachel Aitchison, Wade VanderWright, Amanda Arnold, Dr. Samm Sherman, Dr. Alifa Haque, Prof Nicholas K. Dulvy.

Citation

Jay H. Matsushiba, David Ruiz-García, Rachel M. Aitchison, Wade J. VanderWright, C. Samantha Sherman, Alifa Bintha Haque, Nicholas K. Dulvy. ocean3d: An R Package for Three-Dimensional Spatial Analyses of Marine Habitat.