# Clipping and stitching rasters

SimpleSDMLayers.clipFunction
clip(layer::T, p1::Point, p2::Point) where {T <: SimpleSDMLayer}

Return a raster by defining a bounding box through two points. The order of the points (in terms of bottom/top/left/right) is not really important, as the correct coordinates will be extracted.

source
clip(layer::T; left=nothing, right=nothing, top=nothing, bottom=nothing) where {T <: SimpleSDMLayer}

Clips a raster by giving the (optional) limites left, right, bottom, and top.

source
clip(origin::T1, destination::T2) where {T1 <: SimpleSDMLayer, T2 <: SimpleSDMLayer}

Clips a layer by another layer, i.e. subsets the first layer so that it has the dimensions of the second layer. This operation applies a very small displacement to the limits (5eps()) to ensure that if the coordinate to cut at falls exactly on a cell boundary, the correct cell will be used in the return layer.

source
clip(layer::T, records::GBIF.GBIFRecords)

Returns a clipped version (with a 10% margin) around all occurences in a GBIFRecords collection.

source
Base.vcatFunction
Base.vcat(l1::T, l2::T) where {T <: SimpleSDMLayers}

Adds the second layer under the first one (according to coordinates), assuming the strides and left/right coordinates match. This will automatically re-order the layers if the second is above the first.

source
Base.hcatFunction
Base.hcat(l1::T, l2::T) where {T <: SimpleSDMLayers}

Adds the second layer to the right of the first one (according to coordinates), assuming the strides and left/right coordinates match. This will automatically re-order the layers if the second is to the left the first.

source
SimpleSDMLayers.mosaicFunction
mosaic(f::TF, layers::Vector{T}) where {TF <: Function, T <: SimpleSDMLayer}

Joins a series of possibly overlapping layers by applying the function f to the values that occupy the same cells. Note that the function f should return a single value and accept an vector as input. Functions like Statistics.mean, etc, work well.

Using mosaic with maximum is equivalent to raster::merge from the R package raster.

source