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.SimpleSDMLayer
— TypeAll 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}
.
SimpleSDMLayers.SimpleSDMResponse
— TypeA response is a SimpleSDMLayer
that is mutable, and is the usual type to store analysis outputs. You can transform a response into a predictor using convert
.
SimpleSDMLayers.SimpleSDMPredictor
— TypeA 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.
Getting the coordinates
SimpleSDMLayers.latitudes
— Functionlatitudes(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.
latitudes(records::GBIFRecords)
Returns the non-missing latitudes.
SimpleSDMLayers.longitudes
— Functionlongitudes(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.
longitudes(records::GBIFRecords)
Returns the non-missing longitudes.
SimpleSDMLayers.boundingbox
— Functionboundingbox(layer::T) where {T <: SimpleSDMLayer}
Returns the bounding coordinates of a layer as NamedTuple
.
Type conversion
Base.convert
— FunctionBase.convert(::Type{SimpleSDMResponse}, layer::T) where {T <: SimpleSDMPredictor}
Returns a response with the same grid and bounding box as the predictor.
Base.convert(::Type{SimpleSDMPredictor}, layer::T) where {T <: SimpleSDMResponse}
Returns a predictor with the same grid and bounding box as the response.
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.
Base.convert(::Type{Matrix}, layer::T) where {T <: SimpleSDMLayer}
Returns the grid as an array.