Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collect(skipmissing(::RasterStack)) fails #765

Open
asinghvi17 opened this issue Sep 26, 2024 · 4 comments
Open

collect(skipmissing(::RasterStack)) fails #765

asinghvi17 opened this issue Sep 26, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@asinghvi17
Copy link
Collaborator

# Prepare a test dataset
rs = RasterStack((Raster(rand(X(1:10), Y(1:10)); missingval=NaN) for _ in 1:4)...; missingval = NaN)
# Create areas of known zero, just for verification
map(rs) do A
    A[1:2, 1:2] .= 0
    A[3:4, 3:4] .= NaN
    A
end
rs = replace_missing(rs, missing)
rs[Extent(X=(3,4),Y=(3,4))] |> skipmissing |> collect
ERROR: Use iterate(layers(s)) rather than `iterate(s)`
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] iterate(::RasterStack{…})
   @ DimensionalData ~/.julia/dev/DimensionalData/src/stack/stack.jl:169
 [3] iterate(::Base.SkipMissing{RasterStack{…}})
   @ Base ./missing.jl:252
 [4] _collect(cont::UnitRange{Int64}, itr::Base.SkipMissing{RasterStack{…}}, ::Base.HasEltype, isz::Base.SizeUnknown)
   @ Base ./array.jl:770
 [5] collect(itr::Base.SkipMissing{RasterStack{…}})
   @ Base ./array.jl:759
 [6] |>(x::Base.SkipMissing{RasterStack{…}}, f::typeof(collect))
   @ Base ./operators.jl:917
 [7] top-level scope
@asinghvi17
Copy link
Collaborator Author

I specifically want to iterate over namedtuples here.

@rafaqz
Copy link
Owner

rafaqz commented Sep 27, 2024

Yeah AbstractDimStack doesn't iterate like that.

Maybe it should. For now you can iterate over (stack[I] for I in DimIndices(stack))

@rafaqz
Copy link
Owner

rafaqz commented Nov 2, 2024

This is fixed in the latest DD, so will be fixed here in the next breaking change

@rafaqz rafaqz closed this as completed Nov 2, 2024
@rafaqz rafaqz reopened this Nov 2, 2024
@rafaqz
Copy link
Owner

rafaqz commented Nov 2, 2024

Opps actually not sure SkipMissing will work, lets test that it does

@rafaqz rafaqz added the enhancement New feature or request label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants