Question

Compress Geo-tiff Using JPEG compression (keeping Alpha Band)

  • 19 December 2017
  • 3 replies
  • 32 views

The project I am working on requires that I take geotiffs and compress them using JPEG compression method at a 75 level as well as write them to another projection. The problem is that when I remove the Alpha band (JPEG Compression doesn't support more than 3 bands) it leaves a black border that would normally be transparent with the alpha band still attached.

I could use the LZW compression method, however the size difference after the compression is fairly significant, in comparison to the JPEG compression

Is there a way to insert back in the Alpha band to keep the black border transparent or even a way to clip the black border after the compression.

I should also mention that the black border comes from when the image is projected and slightly turned. Any help would be appreciated!


3 replies

Userlevel 4
Badge +13

Hi @akorte,

There are a couple of options here for you as I see it.

1. Add alpha band and set transparent value for ALL black pixels - this could cause problems is there are real black pixels in the data

2. Extract a bounding box for each raster before Reprojecting and Reproject the box too. Write out the boxes with an attribute for the raster filename. You can use this box to clip away the back boarder.

3. Leave the original images unreprojected when saving to jpeg - then add alpha band and reproject when reading jpeg.

 

Option 2 or 3 are probably your best options for maintaining the data integrity, however, jpeg is a lossy format so if data integrity isn't so important then perhaps option 1 is be worth considering.

Badge +21

This might help?

https://knowledge.safe.com/questions/50739/raster-handle-large-areas-with-no-data.html?childToView=50748#answer-50748

Userlevel 2
Badge +17

Hi @akorte,

If your initial geotiffs edge join into a larger image, you may want to try the following procedure:

  • read all images into workspace
  • mosaic into single image using Rastermosaicker
  • reproject
  • clip back into tiles with the Tiler

This will result in black edges only at the outside of the group of geotiffs.

Another alternative is to create a text string from the bounding coordinates of the valid parts of the image and storing it in the attribute geotiff_tifftag_imagedescription. This will store the string in a tag on the geotiff image, which may be usable in the destination application to clip the image.

Reply