Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Writing and reading with geotiff does not return same dimensions #100

Closed
gabrieldansereau opened this issue May 28, 2021 · 0 comments · Fixed by #101
Closed

Writing and reading with geotiff does not return same dimensions #100

gabrieldansereau opened this issue May 28, 2021 · 0 comments · Fixed by #101

Comments

@gabrieldansereau
Copy link
Member

Probably the same problem as in #99, but I ran into this in a different context so I'll post it in a new issue.

Writing a layer to a .tif file using geotiff() and then re-loading it (again with geotiff) can sometimes return a layer with different dimensions, as in this example:

using SimpleSDMLayers
coords = (left = -145.0, right = -50.0, bottom = 20.0, top = 75.0)

ref = SimpleSDMPredictor(WorldClim, BioClim, 1; coords...)
geotiff("test.tif", ref)
test = geotiff(SimpleSDMPredictor, "test.tif")

isequal(size(ref), size(test)) # not equal, 331 x 571 vs 331 x 570

isequal(ref.left, test.left) # equal
isequal(ref.bottom, test.bottom) # equal
isequal(ref.top, test.top) # equal
isequal(ref.right, test.right) # not equal

ref.right # -50.0
test.right # -50.16666666665

Looking at the exported tif file, the size and bounding coordinates look fine, so the problem is probably with the reading geotiff call (which returned correct dimensions in #99 on the other hand).

using ArchGDAL
d = ArchGDAL.read("test.tif") # correct raster size, 331 x 571
gt = ArchGDAL.getgeotransform(d)
gt[1] + gt[2]*ArchGDAL.width(d) # correct right bound, ≈ 50.0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant