Libraries

We need the following R libraries:

library(sdmpredictors)
library(zoon)

Load equal area rasters and crop with the extent of Europe

We use the package ‘sdmpredictors’ to load environmental data layers from Bio-ORACLE and Marspec.

# Inspect the available datasets and layers
datasets <- list_datasets(terrestrial = FALSE, marine = TRUE)
View(datasets)
layers <- list_layers(datasets)
View(layers)

We select a limited number of layers for this exercise and crop these to a European extent.

layercodes <- c("MS_biogeo05_dist_shore_5m", "MS_bathy_5m", 
                "BO_sstrange", "BO_sstmean", "BO_salinity")
env <- load_layers(layercodes, equalarea = TRUE)
europe <- raster::crop(env, extent(-12e5,25e5, 45e5, 70e5))
plot(europe)

# Data sources
print(layer_citations(layercodes))
## [1] "Tyberghein L, Heroen V, Pauly K, Troupin C, Mineur F and De Clerck O (2012). \"Bio-ORACLE: a global environmental dataset for marine\nspecies distribution modelling.\" _Global Ecology and\nBiogeography_, *21*(2), pp. 272-281. doi:\n10.1111/j.1466-8238.2011.00656.x (URL:\nhttp://doi.org/10.1111/j.1466-8238.2011.00656.x)."
## [2] "Sbrocco EJ and Barber PH (2013). \"MARSPEC: ocean climate layers for marine spatial ecology.\" _Ecology_, *94*(4), pp. 979. doi:\n10.1890/12-1358.1 (URL: http://doi.org/10.1890/12-1358.1)."

Fetch occurrence data for Sepia officinalis

We use the Emodnet Biology webservice to download the using a Geoserver web service. You can find this service URL as follows:

  1. Go to http://www.emodnet-biology.eu/toolbox/en/download/occurrence/select

  2. Search for ‘Sepia officinalis’ in the Taxonomic Search section.

  3. Click on the ‘+’ button. You can now see your selection in the window on the right. Click ‘next’.

  4. Go to ‘Actions’ and select ‘Get webservice URL’. There you go.

occ <- read.csv("http://geo.vliz.be/geoserver/wfs/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=Dataportal%3Aeurobis&resultType=results&viewParams=where%3Aaphiaid+IN+%28141444%5C%2C153098%29&propertyName=datelastmodified%2Ccatalognumber%2Cscientificname%2Caphiaid%2Cscientificname_accepted%2Caphiaidaccepted%2Cyearcollected%2Cmonthcollected%2Cdaycollected%2Clongitude%2Clatitude%2Ccoordinateprecision%2Cminimumdepth%2Cmaximumdepth%2Csex%2Cobservedindividualcount%2Cdatasetid%2Ctaxonlsid&outputFormat=csv")

Species Distribution model

We using the ‘zoon’ package to create a random forest model for the selected species. This is only an example so please be carefull with the interpretation of the result.

## preparation for zoon workflow
points <- SpatialPoints(occ[,c("longitude", "latitude")], lonlatproj)
points <- spTransform(points, equalareaproj)
occfile <- tempfile(fileext = ".csv")
write.csv(cbind(coordinates(points), value=1), occfile)

## workflow

workflow(
  occurrence = LocalOccurrenceData(
    occfile, occurrenceType="presence",
    columns = c("longitude", "latitude", "value")), 
  covariate = LocalRaster(stack(europe)),
  process = OneHundredBackground(seed = 73),
  model = RandomForest,
  output = PrintMap)