Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

PoisotLab/SimpleSDMLayers.jl

Repository files navigation

Simple Layers for Species Distributions Modelling

This package offers very simple types and functions to interact with bioclimatic data and the output of species distribution models.

d_stable d_latest

version CI Doc Coverage

DOI DOI

Curious to know more? Have a look at our paper in Journal of Open Source Software, our JuliaCon poster, our NextJournal demo notebook, and our extended documentation, or keep reading for a quick overview.

Installation

The currently released version of the package can be installed with:

] add SimpleSDMLayers

The package is also designed to work with GBIF, so you may want to use the following line instead:

] add SimpleSDMLayers GBIF

Type system

All types belong to the abstract SimpleSDMLayer, and are organised in the same way: a grid field storing a matrix of data (of any type!), and the left, right, bottom, and top coordinates (as floating point values).

The two core types of the package are SimpleSDMPredictor and SimpleSDMResponse. The only difference between the two is that predictors are immutable, but responses are.

Methods

Most of the methods are overloads from Base. In particular, SimpleSDMLayer objects can be accessed like normal two-dimensional arrays, in which case they return an object of the same type if called with a range, and the value if called with a single position.

It is also possible to crop a layer based on a bounding box:

p[left=left, right=right, bottom=bottom, top=top]

If the layer is of the SimpleSDMResponse type, it is possible to write to it:

p[-74.3, 17.65] = 1.4

This is only defined for SimpleSDMResponse, and SimpleSDMPredictor are immutable.

Bioclimatic data

Data provider Dataset Layers Future models Future scenarios
EarthEnv Landcover 12
EarthEnv HabitatHeterogeneity 14
WorldClim BioClim 19 CMIP6 SharedSocioeconomicPathway
CHELSA BioClim 12 CMIP5 RepresentativeConcentrationPathway

When downloaded (using SimpleSDMPredictor), the layers are stored either in an assets subfolder of the current project (strongly advised against), or at the location determined by the SDMLAYERS_PATH environment variable. The datasets/providers with future models and scenarios also accept years.

Plotting

Using the Plots package, one can call the heatmap, contour, density (requires StatsPlots), and plot methods. Note that plot defaults to a heatmap.

temperature = SimpleSDMPredictor(WorldClim, BioClim, 1)
plot(temperature)

One can also use scatter(l1, l2) where both l1 and l2 are layers with the same dimensions and bounding box, to get a scatterplot of the values. This will only show the pixels that have non-nothing values in both layers. Similarly, histogram2d works.

How to contribute

Please read the Code of Conduct and the contributing guidelines.