Open otfried-cheong opened 2 years ago
@otfried-cheong
Thanks for submitting this issue!
This is indeed a common practice, GDAL even has a documentation section about this.
This feature was simply not yet requested, and I never came around to actually implement it. The solution you propose looks not too bad to me, I would be happy to accept it as a PR, if you'd like to create one. Of course, we would need to come up with a proper way to test this, though.
Thanks, that link explains a lot. Now I finally know how to create such files myself:
gdal_translate -of GTiff -co "SPARSE_OK=TRUE" -co "COMPRESS=DEFLATE" a.tif b.tif
I will prepare a PR with the patch and test cases.
+1
We regularly encounter geotiff files that geotiff.js cannot read (it throws an exception in
readRasters
).After some debugging it turns out that the problem is that these images contain tiles or strips with zero bytes:
I'm not sure if this is actually legal according to the tiff spec, but there seems to be some commonly used software around that produces such files - it simply omits the tile when it only contains nodata.
I have fixed this for our use case by adding this:
in
geotiffimage.js
getTileOrStrip
just before thefetch
. This isn't quite correct - the type of the buffer should be correct for the sample - but it works for the files I've tested with.Unfortunately I don't have an example file that I can share (and haven't figured out how to produce one).