Skip to content

Commit

Permalink
bug: SurfaceRangeEnvelope
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot committed Oct 15, 2023
1 parent eef092e commit b34473c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/pseudoabsences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ cells for the pseudo-absence mask are (i) within the bounding box of the _layer_
(use `SurfaceRangeEnvelope` to use the presences bounding box), and (ii) valued in the
layer.
"""
function pseudoabsencemask(
::Type{RandomSelection},
presences::T) where {T <: SimpleSDMLayer}
function pseudoabsencemask(::Type{RandomSelection}, presences::T) where {T <: SimpleSDMLayer}
_layer_works_for_pseudoabsence(presences)
presence_only = mask(presences, presences)
background = replace(similar(presences, Bool), false => true)
Expand All @@ -193,8 +191,16 @@ function pseudoabsencemask(::Type{SurfaceRangeEnvelope}, presences::T) where {T
_layer_works_for_pseudoabsence(presences)
presence_only = mask(presences, presences)
background = replace(similar(presences, Bool), false => true)
for occupied_cell in keys(presence_only)
background[occupied_cell] = false
lon = extrema([k[1] for k in keys(presence_only)])
lat = extrema([k[2] for k in keys(presence_only)])
for occupied_cell in keys(presences)
if lon[1] <= occupied_cell[1] <= lon[2]
if lat[1] <= occupied_cell[2] <= lat[2]
if ~(presences[occupied_cell])
background[occupied_cell] = true
end
end
end
end
return background
end
Expand Down

0 comments on commit b34473c

Please sign in to comment.