Indexing interface

In versions prior to 0.8, the indexing syntax (x[y]) had been a little bit abused to mean two different things: getting data out of a raster, and getting a raster out of a raster. Starting from 0.8, the indexing interface (i.e. anything relying on getindex and setindex!) is used to act on values. The resizing of rasters is now handled by the clip function.

Getting values out of a raster

Base.getindexFunction
Base.getindex(layer::T, i::CartesianIndex{2}) where {T <: SimpleSDMLayer}

Returns the value stored at a given cartesian index.

source
Base.getindex(layer::T, i::Integer) where {T <: SimpleSDMLayer}

Returns the value stored at a linear index (a good candidate for deprecation as we have a better iteration interface now).

source
Base.getindex(layer::T, i::Integer, j::Integer) where {T <: SimpleSDMLayer}

Standard abstract array accession, where the dimensions follow the dimensions of the underlying grid.

source
Base.getindex(layer::T, i::Array{CartesianIndex{2}}) where {T <: SimpleSDMLayer}

Returns an array of values based on an array of cartesian indices - this can be a vector or a matrix, and the elements can be in any order. This will not return a raster.

source
Base.getindex(layer::T, longitude::AbstractFloat, latitude::AbstractFloat) where {T <: SimpleSDMLayer}

Returns a value by longitude and latitude.

source
Base.getindex(layer::T, c::Point) where {T <: SimpleSDMLayer}

Access a value through a Point (from GeometryBasics), which has the longitude first and the latitude last – this follows the GeoJSON convention.

source
Base.getindex(layer::T, c::Array{<:Point}) where {T <: SimpleSDMLayer}

Access a value through an array of Point (from GeometryBasics), which has the longitude first and the latitude last. The array can be in any order, so this method will not return a raster.

source
Base.getindex(::T, ::Nothing) where {T <: SimpleSDMLayer}

If the user requests a point that is out of bounds, its cartesian coordinate will be matched to nothing, and then we return nothing.

source
Base.getindex(p::T, occurrence::GBIF.GBIFRecord) where {T <: SimpleSDMLayer}

Extracts the value of a layer at a given position for a GBIFRecord. If the GBIFRecord has no latitude or longitude, this will return nothing.

source
Base.getindex(layer::T, records::GBIF.GBIFRecords) where {T <: SimpleSDMLayer}

Returns the values of a layer at all occurrences in a GBIFRecords collection.

source
Base.getindex(layer::T, records::Vector{GBIF.GBIFRecord}) where {T <: SimpleSDMLayer}

Returns the values of a layer at all occurrences in a GBIFRecord array.

source

Writing values in a raster

Base.setindex!Function
Base.setindex!(layer::T, v, record::GBIFRecord) where {T <: SimpleSDMResponse}

Changes the values of the cell including the point at the requested latitude and longitude. Be careful, this function will not update a cell that has nothing.

source