# Types

Layers are represented by a grid, storing the content of cells in a Matrix, and a bounding box indicated by the floating point coordinates of its limits.

## Implemented types

SimpleSDMLayers.SimpleSDMLayerType

All types in the package are part of the abstract type SimpleSDMLayer. A SimpleSDMLayer has five core fields: grid is a matrix storing the cells, and left, right, bottom and top are floating point numbers specifying the bounding box.

It is assumed that the missing values will be represented as nothing, so internally the matrix will have type Union{T, Nothing}.

source
SimpleSDMLayers.SimpleSDMPredictorType

A predictor is a SimpleSDMLayer that is immutable, and so does not have methods for setindex!, etc. It is a safe way to store values that should not be modified by the analysis. Note that if you are in a bind, the values of the grid field are not immutable, but don't tell anyone we told you. The correct way of handling predictors you need to modify would be to use convert methods.

source

## Getting the coordinates

SimpleSDMLayers.latitudesFunction
latitudes(layer::T) where {T <: SimpleSDMLayer}

Returns an iterator with the latitudes of the SDM layer passed as its argument. This returns the latitude at the center of each cell in the grid.

source
latitudes(records::GBIFRecords)

Returns the non-missing latitudes.

source
SimpleSDMLayers.longitudesFunction
longitudes(layer::T) where {T <: SimpleSDMLayer}

Returns an iterator with the longitudes of the SDM layer passed as its argument. This returns the longitudes at the center of each cell in the grid.

source
longitudes(records::GBIFRecords)

Returns the non-missing longitudes.

source

## Type conversion

Base.convertFunction
Base.convert(::Type{SimpleSDMResponse}, layer::T) where {T <: SimpleSDMPredictor}

Returns a response with the same grid and bounding box as the predictor.

source
Base.convert(::Type{SimpleSDMPredictor}, layer::T) where {T <: SimpleSDMResponse}

Returns a predictor with the same grid and bounding box as the response.

source
Base.convert(::Type{T}, layer::TL) where {T <: Number, TL <: SimpleSDMLayer}

Returns a copy of the layer with the same type (response or predictor), but the element type has been changed to T (which must be a number). This function is extremely useful (required, in fact) for plotting, as the nothing values are changed to NaN in the heatmaps.

source
Base.convert(::Type{Matrix}, layer::T) where {T <: SimpleSDMLayer}

Returns the grid as an array.

source