[gdal-dev] gdalwarp ERROR 6: PHOTOMETRIC=YCBCR requires a source raster with only 3 bands (RGB)

Even Rouault even.rouault at spatialys.com
Sun Jul 1 14:42:33 PDT 2018


On dimanche 1 juillet 2018 11:18:39 CEST Stephen Woodbridge wrote:
> Right, but the point 1 is the message says:
> ERROR 6: PHOTOMETRIC=YCBCR requires a source raster with only 3 bands (RGB)
> ie: requires a source raster with only 3 bands (RGB) and the source
> raster has only 3 bands!
> -dstalpha if I understand correctly is to create a alpha band in the
> output file. So the error message is misleading at best.

I've adjusted the error message

> 
> Point 2 is how does one translate a utm to wgs84 using YCBCR and
> generate an appropriate mask or alpha channel to hide the pixels that
> are outside the transformed image. I suppose it needs to be done in
> multiple steps of warp and translate in some specific order with
> specific options but its not obvious how.

try:

gdalwarp -t_srs EPSG:4326 -dstalpha -r bilinear -of GTiff \
	 -co TILED=YES '00010.jp2' 'tif/00010_rgba.tif'
gdal_translate -b 1 -b 2 -b 3 -mask 4 -co BIGTIFF=YES -co TILED=YES \
	 -co COMPRESS=JPEG -co JPEG_QUALITY=90 -co PHOTOMETRIC=YCBCR \
	 --config GDAL_TIFF_INTERNAL_MASK YES \
	 'tif/00010_rgba.tif' 'tif/00010_rgb_with_mask.tif'

Potentially to save space / time, you can warp to VRT in the first step;

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list