-
Notifications
You must be signed in to change notification settings - Fork 37
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
open
returns a corrupted Raster
#884
Comments
Hmm I guess it should return the original unopened object (its not corrupted, just closed) The problem is you may want to return a value so it's a bit tricky.
|
Still don't know exactly what is going on, but I figured out this doesn't happen when just lazily reading the same raster (only after Rasters.create) - but if I specify a missingval then for whatever reason it does! using Rasters, RasterDataSources, ArchGDAL, NCDatasets
ras = Raster(WorldClim{Climate}, :tmin, month = 1, lazy = true)
ras2 = Rasters.create("myraster.nc", ras, force = true)
ras3 = Raster("myraster.nc"; lazy = true, missingval = missing)
ras4 = Raster("myraster.nc"; lazy = true)
for (i, r) in enumerate((ras, ras2, ras3, ras4))
println("Opening ras$i")
try
open(identity, r) |> size
catch
println("Errored!")
end
end
|
I think the variability is whether it's wrapped in another array or not. But do note that using the outputs of open has to be undefined behaviour unless we decide to flatten and reconstruct back to FileArray. The whole point of the closure is that it closes the dataset at the end... And you are passing the dataset out (with |
Okay the second example with I think the main problem here is that you do a totally valid operation and then get a long stacktrace with a |
Hm the reason the last example doesn't error is that |
I does! But.. |
Then we should at least document that. If I don't know any of this (which untill yesterday I didn't, really) and I want to lazily multiply a file by 2, just from reading the docstring of
And this works like a charm if ras is a .tif, but if it's a .nc I need to add I can see now why this is tricky to solve, but probably we can improve at least the documentation so that it's not as easy to go wrong - especially because that backend matters here. |
You don't need to use open to do anything lazily. It shouldn't work with a tiff... I think it's not lazy? The solution is a fairly easy with Flatten.jl, just need to do it |
You do if you want to write to it? Or am I missing something obvious? |
But writing isn't lazy? And again you shouldnt return the written values. But I am convinced we should swap the arrays for FileArray if they are returned, I just need to finish the Zarr PR first as it changes a lot of this |
In some cases if I create a Raster with
Rasters.create
, and then open it, the returnedRaster
returns a NetCDF error on show (or pretty much any other operation).This is pretty hard to reproduce for some reason and it depends on
ras
. Usingras = Raster(rand(X(1:10), Y(1:10)))
it doesnt errorStacktrace
The text was updated successfully, but these errors were encountered: