sul-dlss / gis-robot-suite

Robots for GIS accessioning and delivery
Other
9 stars 4 forks source link

Optionally add alpha channel to GeoTIFFs #790

Open edsu opened 8 months ago

edsu commented 8 months ago

Blocked by #789

The add_alpha step in normalize_data can sometimes take a very long time. For example try running this gdalwarp command using this 001.tif in this Google shared folder: https://drive.google.com/drive/folders/1gY6_SgLWwJhtJrYsiAG5X5kgda741Lyo

gdalwarp -co 'COMPRESS=LZW' -dstalpha 001.tif new.tif

It ran on my MacBook Pro for 5 hours...but did ultimately finish whew...

Not all TIFFs need an alpha channel added. We should use gdalinfo to check and see if the GeoTIFF already has an alpha channel, and only add it if it doesn't. To determine if the alpha channel is already there look in the .bands stanza of the JSON output, and inspect each one to see if the colorInterpretation is set to Alpha.

Before:

$ gdalinfo -json 001.tif | jq '.bands[].colorInterpretation'
"Red"
"Green"
"Blue"

After:

$ gdalinfo -json new.tif | jq '.bands[].colorInterpretation'
"Red"
"Green"
"Blue"
"Alpha
edsu commented 8 months ago

This ticket is no longer relevant since the original approach to creating the transparency layer has not seemed to work #570