DimensionalData.jl icon indicating copy to clipboard operation
DimensionalData.jl copied to clipboard

Are there any helper functions for extending a dimension of an DimArray

Open alex-s-gardner opened this issue 8 months ago • 5 comments

I have a DimArray

da = rand(X(1:10), Y(1:10))

And later in my workflow I'd like add values at X == 11. Right now that looks like:

da2 = fill(NaN, X(1:11), Y(1:10)) da2[At(1:10), : ] = da; da = da2

This looks a bit uglier as the number of dims grow. I'm wondering if my current approach is best practice or if there is a helper function (that I haven't been able to find) to simplify this operation as I'm guessing this operation is relatively common.

alex-s-gardner avatar Apr 08 '25 23:04 alex-s-gardner

~cat(da1, da2; dims=X) ?~ (Hmm maybe I don't totally get what you're doing)

Rasters has extend, maybe that's what you want.

I guess Rasters should just accept any AbstractDimArray, the problem is what to use for the missing values

rafaqz avatar Apr 09 '25 08:04 rafaqz

Could always force a kwarg fill...

asinghvi17 avatar Apr 09 '25 11:04 asinghvi17

cat() is what I was looking for, thanks.

da = rand(X(1:10), Y(1:10))
da2 = fill(NaN, X(11:11), Y(1:10))
da = cat(da, da2, dims=:X)

alex-s-gardner avatar Apr 09 '25 15:04 alex-s-gardner

This would still be nice to have

asinghvi17 avatar Apr 09 '25 16:04 asinghvi17

We could move extend here I guess.

rafaqz avatar Apr 09 '25 16:04 rafaqz