YAXArrays.jl
YAXArrays.jl copied to clipboard
Cannot save cube with y and x axis to tiff
I try to save a data cube with the following dimensions as a geotiff file
julia> wcororiginal
YAXArray with the following dimensions
y Axis with 5820 Elements from 561609.15 to 736179.15
x Axis with 7500 Elements from 9.48724066e6 to 9.26227066e6
name: layer
Total size: 166.51 MB
julia> savecube(wcororiginal, "data/s1cube_jurua_watercorrelation.tiff")
ERROR: Did not find x, y or lon, lat dimensions in dataset
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] create_dataset(::Type{YAXArrayBase.GDALDataset}, outpath::String, gatts::Dict{String, Any}, dimnames::Vector{String}, dimvals::Vector{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, dimattrs::Vector{Dict{String, Any}}, vartypes::Vector{DataType}, varnames::Vector{String}, vardims::Vector{Vector{String}}, varattrs::Vector{Dict{String, Any}}, varchunks::Vector{Tuple{Int64, Int64}}; userproj::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ YAXArrayBase ~/.julia/packages/YAXArrayBase/R6Frw/src/datasets/archgdal.jl:161
[3] create_dataset(::Type{YAXArrayBase.GDALDataset}, outpath::String, gatts::Dict{String, Any}, dimnames::Vector{String}, dimvals::Vector{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, dimattrs::Vector{Dict{String, Any}}, vartypes::Vector{DataType}, varnames::Vector{String}, vardims::Vector{Vector{String}}, varattrs::Vector{Dict{String, Any}}, varchunks::Vector{Tuple{Int64, Int64}})
@ YAXArrayBase ~/.julia/packages/YAXArrayBase/R6Frw/src/datasets/archgdal.jl:134
[4] savedataset(ds::Dataset; path::String, persist::Nothing, overwrite::Bool, append::Bool, skeleton::Bool, backend::Symbol, driver::Symbol, max_cache::Float64, writefac::Float64)
@ YAXArrays.Datasets ~/.julia/packages/YAXArrays/Fe7F8/src/DatasetAPI/Datasets.jl:503
[5] savecube(c::YAXArray{Union{Missing, Float32}, 2, DiskArrays.SubDiskArray{Union{Missing, Float32}, 2}, Vector{CubeAxis}}, path::String; name::String, datasetaxis::String, max_cache::Float64, backend::Symbol, driver::Symbol, chunks::Nothing, overwrite::Bool, append::Bool, skeleton::Bool, writefac::Float64)
@ YAXArrays.Datasets ~/.julia/packages/YAXArrays/Fe7F8/src/DatasetAPI/Datasets.jl:566
[6] savecube(c::YAXArray{Union{Missing, Float32}, 2, DiskArrays.SubDiskArray{Union{Missing, Float32}, 2}, Vector{CubeAxis}}, path::String)
@ YAXArrays.Datasets ~/.julia/packages/YAXArrays/Fe7F8/src/DatasetAPI/Datasets.jl:548
[7] top-level scope
@ REPL[109]:1
This is because we check for the dimension names for the first and second dimension and expect x to be first and the y axis to be second.
Could we do this check in the savedataset function and permute the dimensions there? I tried to permute the dimensions in the outer core, but to_dataset ignores the permutation when the cube is converted into a Dataset before saving it to disk.
Something is really strange here, there seems to be a difference if you use capital or minor letters as well. This is as far as I got, but still resulting in a GDAL error:
using YAXArrays, ArchGDAL
const AG = ArchGDAL
a = YAXArray([RangeAxis("Y",1:10),RangeAxis("X",1:20)],rand(10,20),Dict("projection_PROJ4"=>"+proj=longlat +datum=WGS84 +no_defs"))
savecube(permutedims(a,(2,1)),"./testwrite.tif",overwrite=true)