Skip to content

Fix writing multiband GeoTiff with compression - #2246

Merged
lossyrob merged 3 commits into
locationtech:masterfrom
lossyrob:fix/geotiff-multiband-compression
Jun 22, 2017
Merged

lossyrob merged 3 commits into
locationtech:masterfrom
lossyrob:fix/geotiff-multiband-compression

Conversation

@lossyrob

Copy link
Copy Markdown
Member

Ass reported by @stevekuo on Gitter:

I'm seeing GeoTiffOptions(DeflateCompression) being correctly observed with SinglebandGeoTiff, but ignored with MultibandGeoTiff.
Roughly my code is

val geotiff = SinglebandGeoTiff(tile, extent, crs, Tags.empty, GeoTiffOptions(DeflateCompression))
// OR
val geotiff = MultibandGeoTiff(tile, extent, crs, Tags.empty, GeoTiffOptions(DeflateCompression))

val geotiffArray = GeoTiffWriter.write(geotiff)
val stream = new ByteArrayInputStream(geotiffArray)

I then write out to a file. Using gdalinfo, the single band is COMPRESSION=DEFLATE, where as the multi band is not compressed.

This fixes the oversight that was causing the GeoTiff to be written as uncompressed.

@lossyrob lossyrob added this to the 1.1 milestone Jun 21, 2017
@stevekuo

stevekuo commented Jun 21, 2017 •

Copy link
Copy Markdown

tile is a MultibandTile. Workaround is to convert MultibandTile to MultibandGeoTiff and specify the GeoTiffOptions.

val geotiffTile = GeoTiffMultibandTile(tile, options)
MultibandGeoTiff(geotiffTile, extent, metadata.crs, Tags.empty, options)

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 this pull request may close these issues.

3 participants