Skip to content

Calling boundingbox on a set of occurrences should ignore the occurrences with no coordinates #409

@tpoisot

Description

@tpoisot

Currently, calculating the boundingbox for a set of occurrences returns a tuple with missing elements, if some occurrences do not have coordinates — this happens when GBIF requests don't use the hasCoordinate flag, for example.

So it seems like something should be wrapped into a skipmissing

This will most likely take place here:

function boundingbox(occ::AbstractOccurrenceCollection; padding=0.0)
left, right = extrema(longitudes(occ))
bottom, top = extrema(latitudes(occ))
return _padbbox(left, right, bottom, top, padding)
end

The lon/lat are returned from the following methods

"""
longitudes(o::AbstractOccurrence)
Returns the longitude for a single occurrence
"""
longitudes(o::T) where {T <: AbstractOccurrence} = ismissing(place(o)) ? missing : first(place(o))
"""
latitudes(o::AbstractOccurrence)
Returns the latitude for a single occurrence
"""
latitudes(o::T) where {T <: AbstractOccurrence} = ismissing(place(o)) ? missing : last(place(o))
longitudes(o::T) where {T <: AbstractOccurrenceCollection} = longitudes.(elements(o))
latitudes(o::T) where {T <: AbstractOccurrenceCollection} = latitudes.(elements(o))
longitudes(o::Vector{<:T}) where {T <: AbstractOccurrence} = longitudes.(o)
latitudes(o::Vector{<:T}) where {T <: AbstractOccurrence} = latitudes.(o)

Metadata

Metadata

Assignees

No one assigned

    Labels

    🏖️ low effortIssue that can be tackled without too much problem📦 SDTLikely to be solved in the top-level package🤗 good first PRIssue that's small / straightforward enough to be a good first PR

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions