-
Notifications
You must be signed in to change notification settings - Fork 18
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
How to add variable to existing cube? #65
Comments
You have to compute a new ndvicube, but this is all done lazily and you don't have to save it to disk. julia> arr = rand(300,200,90, 4)
julia> x = RangeAxis(:X, 1:300)
X Axis with 300 Elements from 1 to 300
julia> y = RangeAxis(:Y, 1:200)
Y Axis with 200 Elements from 1 to 200
julia> t = RangeAxis(:time, 1:90)
time Axis with 90 Elements from 1 to 90
julia> b = CategoricalAxis("Bands", ["Red", "Green", "Blue", "NIR"])
Bands Axis with 4 elements: Red Green Blue NIR
julia> yax = YAXArray([x,y,t,b], arr)
YAXArray with the following dimensions
X Axis with 300 Elements from 1 to 300
Y Axis with 200 Elements from 1 to 200
time Axis with 90 Elements from 1 to 90
Bands Axis with 4 elements: Red Green Blue NIR
Total size: 164.79 MB
julia> ndvi = map((r,nir) ->(r-nir)/(r+nir),yax[Bands="Red"], yax[Bands="NIR"]) If you would like to combine the datasets again into a cube together you would have to split the cube and concatenate it again.
|
Hi, As in the example below, add the dir axis into the cube:
Thanks! |
Hi, again to elaborate some stuff, maybe there is an easy fix for that, maybe its useful... so my xarray from python, (where i added the metadata for now) looks something like this: `<xarray.Dataset>
Trying to open this again in YAXArray for processing now fails like the following: `julia> YAXArrays.open_dataset("cube_from_above.zarr") [1] getindex(h::Dict{String, UnionAll}, key::String) However changing the String Variables to Bool seems to work just fine, so Float and Bool do not throw errors. `<xarray.Dataset>
`julia> YAXArrays.open_dataset("cube_bool.zarr") YAXArray Dataset Cheers! |
Hi, thanks for the report. What you describe seems to be a Zarr error and should be fixed in Zarr.jl. Could you post the contents of the file "cube_from_above.zarr/sat/.zarray" and "cube_from_above.zarr/dir/.zarray"? We support several string data types in Zarr.jl, but there seem to be too many of them in numcodecs. |
cube_from_above.zarr/sat/.zarray:
cube_from_above.zarr/dir/.zarray:
|
just an update: However, when saving, those properties are not kept:
|
The saving of the properties will be fixed by #117. Is there anything else, that should be done here? |
see https://juliadatacubes.github.io/YAXArrays.jl/dev/UserGuide/write.html#Append-to-a-Dataset for a cleaner way when it comes to append new variables. |
Hi!
I have a cube e.g. with axes X,Y,Time, and Bands. Bands contains "NIR" and "RED" variables. How would I add a "NDVI" variable to Bands for each time step? Is that possible or do I have to compute a new "ndvi-cube" and combine or merge them?
Thanks in advance
Bjoern
The text was updated successfully, but these errors were encountered: