ArchGDAL.jl
ArchGDAL.jl copied to clipboard
Tif files are not always chunked
https://github.com/yeesian/ArchGDAL.jl/blob/6d67ee60bfdc3cd680c57efa3bc504bbeae088cb/src/raster/array.jl#L106-L107
There is TILED=NO for the GTiff driver, so Chunked is not always true. I'm not sure what the function is to check if a band is chunked or not, but we should use it.
This can be a problem for gdal, giving a Bad value 514 for "TileWidth" tag error if you try to set the tile size to the chunk size,
or a problem for DiskArrays with an error broadcasting different chunk sizes... when in fact there are no chunks.
This may be an issue with the difference between GDALs "natural" and actual block sizes.
Do we need to compare blocksize(rasterband) with (width(rasterband), height(rasterband))?
Yeah maybe. I'm wondering if @meggart had a reason for always using Chunked()
Afaik, even if with no tiling, you end up with blocks (that are single rows). In that sense there always is a chunk.
I can imagine though that setting tile options on a non tiled rasters results in errors. @rafaqz can you give a mwe for that error you mentioned?
Yeah maybe. I'm wondering if @meggart had a reason for always using Chunked()
No, I did not know that there is a TILED=NO and I just assumed GDAL datasets are tiled. I would be happy to do a check here e.g. as @yeesian suggested, by comparing blocksize with the actual size of the band.
Just to drop this here:
gds = GDAL.gdalopen(somefile, GDAL.GA_ReadOnly)
infoopts = GDAL.gdalinfooptionsnew(C_NULL, C_NULL)
info = GDAL.gdalinfo(gds, infoopts)
info = split(info)
filter(contains("Block"), info)
GDAL.gdalinfooptionsfree(infoopts)
GDAL.gdalclose(gds)
This is neither fast nor solid, but retrieves the block size.