-
Notifications
You must be signed in to change notification settings - Fork 36
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
Move to using getproperty
for accessing RasterStack
layers?
#231
Comments
getproperty
for accessing RasterStack
layersgetproperty
for accessing RasterStack
layers?
I'm trying hard to remember back to when we first discussed this weirdness. I think I was advocating hyperdimensional arrays where time is an index but there were issues with that setup too. We never thought of using the What would be the alternative for |
I never thought about it before either, I just realised the other day that its actually the main way to index a I don't know what an alternative to that getindex example could be, I really like it as-is honestly, and that its exactly the same as for an array. Others seem to as well, @maxfreu wanted to use Maybe we could use another function name for indexing stacks, but the |
Completed |
It would be nice if we could use
Symbol
andString
to to access categorical variables in DimensionalData.jl and inheriting packages, without wrapping them withAt
. But there are some edge cases where that clashes withDimStack/RasterStack
getindex
syntax, and will effect users of Rasters.jl the most.rafaqz/DimensionalData.jl#338 (comment)
The problem generally is that
DimStack/RasterStack
overloads theArray/NamedTuple
combination, in ways that are sometimes confusing, but also pretty powerful. Currently we usegetindex
of a singleSymbol
to retrieve a stack layer, and any othergetindex
to retrieve the values of all of theRaster
layers, or slice them all.I'm considering migrating the syntax to
getproperty
, like this:Then
rasterstack[args...]
is always indexing the values of the layers, and never fetching a layer (after a period of depreciation)There are probably a few more changes like this that need to happen, because as @mkborregaard has said,
RasterStack
getindex
is pretty weird -first(rasterstack)
returns a singleRaster
layer whilerasterstack[1]
returns aNamedTuple
of the first value of all the layers !!!. This is because iteration happens over whole layers, like aNamedTuple
ofArray
, but forgetindex
a stack is is like anArray
ofNamedTuple
.We might need to contain that weirdness somehow. One option is to not use
getindex
for retrieving values at all, which resolves the problem. But then you can't do:Which is one of the main things I do with a
RasterStack
after loading a netcdf. If anyone has any thoughts or feedback, that would be great, I don't want to break everyones workflow unless it makes sense.@vlandau @mauro3 @mkborregaard @jamesmaino @virgile-baudrot
The text was updated successfully, but these errors were encountered: