[gdal-dev] What is the best strategy for handling multiple banded tiffs

Stephen Woodbridge woodbri at swoodbridge.com
Wed Apr 12 10:23:06 PDT 2017


Hi all,

I'm reworking my code dealing with NAIP imagery that has R, G, B, IR 
bands, and I generate a mask band when reprojecting it. I also have the 
option to generate another computed band based on a sobel operator.

In the past, I separated them R, G, B, mask into jpeg ycbcr compressed 
tiff and had separate files for the IR, and the sobel data and used a 
VRT file to pull all these together into a single image for additional 
processing.

Ideally, I would like to have one file, rather than 4 files (RGB, IR, 
sobel, and the VRT) because over large areas the management of all these 
files is a pain. Also when displaying and working with large areas I 
need to mosaic the images into a seemless area using a vrt file or 
tileindex.

I need a way to display the various bands, and mapserver is my tool of 
choice, but I probably need to be able to display them via qgis also, 
which I have not experience with but reading older posts, I might need 
to create a vrt file. In mapserver I can select bands using PROCESSING 
options on layers.

Questions?

1. Does it make sense to try and do this with one tiff with 6 bands?
2. What would be the best workflow for doing this? I'm thinking 
something like:

# remove any collar
nearblack -co TILED=YES -of GTiff -nb 0 -near 0 -setmask -q -o temp1.tif 
doqq.tif

# warp to EPSG:4326 (does -dstalpha convert mask band to an alpha band?)
gdalwarp -t_srs EPSG:4326 -dstalpha -co TILED=YES temp1.tif rgba.tif

# make sobel gray scale single band image
makesobel.py rgba.tif sobel.tif

# create a temp.vrt file with bands R, G, B, Alpha|mask, IR, sobel

# and finally build a tif using the temp.vrt
# I'm not sure what is the best way build the final tif given the mask
# and whether I should use gdalwarp or gdal_translate for this step
gdal_translate -co TILED=YES -co JPEG_QUALITY=90 -co COMPRESS=JPEG 
--CONFIG GDAL_TIFF_INTERNAL_MASK YES temp.vrt final.tif

# and build overviews
gdaladdo -clean -r average final.tif 2 4 8 16 32 64 128

I'm not clear on how the mask band or alpha channel(band?) interacts 
with the various commands at each step in the workflow.

Thanks,
   -Steve

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the gdal-dev mailing list