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

geotiff does not use specified nodata value when writing #108

Closed
gabrieldansereau opened this issue Jun 4, 2021 · 0 comments · Fixed by #106
Closed

geotiff does not use specified nodata value when writing #108

gabrieldansereau opened this issue Jun 4, 2021 · 0 comments · Fixed by #106

Comments

@gabrieldansereau
Copy link
Member

geotiff does not use the specified nodata value when writing to a tif file, whether it's the default -9999 or a custom one. It sets the nodata value for the file with ArchGDAL.setnodatavalue! correctly, but does not use it in the grid itself and uses NaN instead.

Because of this, it is always necessary to call replace(geotiff(SimpleSDMPredictor, file), NaN => nothing) when re-reading a layer after writing it, which in my sense could be avoided.

l = SimpleSDMPredictor(WorldClim, BioClim, 1)

# With -9999 as nodata
f1 = tempname()
geotiff(f1, l) # use -9999 as nodata by default
mp1 = geotiff(SimpleSDMResponse, f1)

length(mp1) == length(l) # false, but should be true
mp1 == l # false, same thing
replace(mp1, NaN => nothing) == l1 # true, but could be avoided

# With custom nodata
f2 = tempname()
geotiff(f2, l; nodata=-3.4f38) # this is the nodata from the WorldClim files
mp2 = geotiff(SimpleSDMPredictor, f2)

length(mp2) == length(l) # false
mp2 == l # false
replace(mp2, NaN => nothing) == l1 # true
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