Skip to content
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

SLC Incorrect Data on Write #502

Closed
joshday opened this issue Aug 21, 2023 · 7 comments · Fixed by #545
Closed

SLC Incorrect Data on Write #502

joshday opened this issue Aug 21, 2023 · 7 comments · Fixed by #545

Comments

@joshday
Copy link

joshday commented Aug 21, 2023

I have a Single Look Complex .tiff file where the underlying data changes on a read-write-read roundtrip.

Data found on https://search.asf.alaska.edu/ (S1A_IW_SLC__1SDV_20230103T230613_20230103T230641_046626_059699_9E8C)

julia> slc = Raster(path);

julia> Rasters.write("test.tiff", slc; force=true)
"test.tiff"

julia> slc2 = Raster(ans);

# data from the "read" matrix and the "read-write-read" matrix are different
julia> slc.data == slc2.data
false

# The errors sum to zero.  An incorrect transpose?
julia> sum(x - y for (x,y) in zip(slc.data, slc2.data))
0 + 0im

julia> mean(abs(x - y) for (x,y) in zip(slc.data, slc2.data))
73.42267370323304

A likely related issue is that the written file is about half the size as the original:

julia> filesize(path)
1186109408

julia> filesize("test.tiff")
673542244

I'll look into this further and add more details as I find them. Just wanted to get an issue in writing.

@rafaqz
Copy link
Owner

rafaqz commented Aug 21, 2023

Sounds BAD. Will try to fix. But can you download the file inline in your MWE?

Otherwise a big chunk of my available bugfix time dissapears looking for demo rasters on various platforms, rather than fixing bugs ;)

@joshday
Copy link
Author

joshday commented Aug 22, 2023

I know it's really annoying to reproduce...I don't think they have an API though. They require an account and all the files are > 1Gb.

My hunch is that is has to do with rotations, but I'll try to get a simpler MWE tomorrow

@rafaqz
Copy link
Owner

rafaqz commented Aug 22, 2023

I just couldnt find the file after 5 mins looking a gave up 😂

@joshday
Copy link
Author

joshday commented Aug 24, 2023

Okay, so looks like an axis gets flipped. Here's the original and roundtrip data heatmaps side by side:

Screenshot 2023-08-24 at 10 43 37 AM

@rafaqz
Copy link
Owner

rafaqz commented Aug 24, 2023

I found a file matching that name on there but it won't even load in GDAL so I'm not sure what you're actually doing - I really need a full MWE here

@joshday
Copy link
Author

joshday commented Aug 24, 2023

Okay, here's some better info.

@rafaqz I sent you a link to download the data. I don't think any SLC data exists in a smaller file, so that's annoying. I can't give you a smaller file but here's some simplified code that identifies the issue:

using Rasters, ArchGDAL

path = "s1a-iw1-slc-vh-20221206t234001-20221206t234026-046218-0588c1-001.tiff"

a = Raster(path)

Rasters.write("temp.tiff", a; force=true)

b = Raster("temp.tiff")  # roundtrip

a.data == b.data  # false

a.data == reverse(b.data, dims=2)  # true

@rafaqz
Copy link
Owner

rafaqz commented Aug 24, 2023

Ok, this is kind of minor problem really. By convention non rotated geotiffs are usually stored with the Y axis flipped, or "north up". So users don't have to do this reversing manually all the time we do it automatically. I guess if there is any kind of rotation we should'nt do that, instead just leaving things how they are.

This is pretty well explained in this stackexchange
https://gis.stackexchange.com/questions/122647/do-rasters-other-than-north-up-exist-in-the-wild

(Thanks for the drive link its super fast to check these things with a file and MWE)

@rafaqz rafaqz mentioned this issue Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants