knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

OBIShmpr

Lifecycle: experimental R build status Codecov test coverage

The goal of OBIShmpr is to link and query OBIS occurence data with a variety of marine habitat data.

Data Sources

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("EMODnet/OBIShmpr")

Example

Get habitat data for a species

library(OBIShmpr)

An example with one species

This is an example of how to run the above code for a single species - we use Scytothamnus fasciculatus, Aphia ID 325567, chosen as it has just 6 OBIS records so should run reasonably quickly.

Choose some layers to extract data from

sp_id <- 325567
layers <- c("BO2_nitratemax_bdmin", "BO_parmax", "BO2_tempmax_bdmax", "permeability", 
"tidal_vel_max", "april")
obis_match_habitat(sp_id, layers = layers)
layer_codes <- c("BO_ph", "BO_phosphate", 
                 "BO2_phosphatemean_bdmax", 
                 "BO_nitrate", "BO2_nitratemean_bdmax", 
                 "surface_nitrogen", "tn", "surface_carbon",
                 "BO_sstmean", "BO_sstmin", "BO_sstmax", 
                 "MS_biogeo13_sst_mean_5m", "MS_biogeo14_sst_min_5m",
                 "MS_biogeo15_sst_max_5m")

Palinurus elephas

Next I use the AphiaID for Palinurus elephas.

species_id <- worrms::wm_name2id("Palinurus elephas")

data <- OBIShmpr::obis_match_habitat(
    sp_id = species_id, 
    layers = layer_codes,
    geometry = bbox_nwes)

data
library(ggplot2)
world <- rnaturalearth::ne_countries(scale = "medium", returnclass = "sf")


ggplot() +
    geom_sf(data = world) +
    geom_sf(data = data, aes(color = BO_ph) ) +
    coord_sf(crs = 3035,
             xlim = c(2426378.0132, 7093974.6215),
             ylim = c(1308101.2618, 5446513.5222)) +
    theme_bw() +
    ggtitle("Palinurus elephas",
            subtitle = paste0('AphiaID = ', species_id))


annakrystalli/OBIShmpr documentation built on Oct. 4, 2020, 6:37 a.m.