5

I downloaded Sentinel-2 data. This data have 13 files one for each band as jp2 format. I am reading this images the writing them as GeoTIFF format on python using rasterio. These images are large so I am applying lossless compression to them. I tried both 'deflate' and 'lzw'. I noticed that when I write a single band the image size reduces significantly (the compressed image is 40% the original image). However, when I write a multiple band image, the image does not reduce and in some cases it increases. Can anyone tell me why is that. Below is how I write the images compressed.

new_dataset11= rio.open(
                      'image_multiband_2A/new_multi11.tif',
                      'w',
                      driver='GTiff',
                      width=band_width,
                      height=band_height,
                      count=len(R10m),
                      crs=band_current.crs,
                      transform=band_current.transform,
                      dtype=band_np.dtype,
                      nodata=0,
                      blockxsize=block_size_width,
                      blockysize=block_size_height,
                      tiled=True,
                      compress='lzw')

1 Answer 1

1

I think the reason is that rasterio can be problematic when working with multiband images. Maybe for this reason the official documentation only describes the compression of a single band image.

So I would recommend to compress the images afterwards with gdal_translate -of GTiff -co COMPRESS=LZW -co BIGTIFF=YES input.tif output.tif.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.