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

Stephen Woodbridge stephenwoodbridge37 at gmail.com
Sun Jul 1 15:02:32 PDT 2018


OK, digging deep into my old emails I think I found a solution ( still 
to be proved):

gdalwarp -t_srs EPSG:4326 -r bilinear -co TILED=YES -co BIGTIFF=YES 
-dstalpha -multi  '00010.jp2' '/data/satmap/tmp.tif'

This took 39 min and expanded the 2.1G jp2 into 87G tif, then this gets 
followed by:

gdal_translate -co TILED=YES -co JPEG_QUALITY=90 -co COMPRESS=JPEG -co 
PHOTOMETRIC=YCBCR -b 1 -b 2 -b 3 -mask 4 --config 
GDAL_TIFF_INTERNAL_MASK YES /data/satmap/tmp.tif /data/satmap/tmp/00010.tif

Which takes 53 min and compresses into a 1.8G tif. And then add overviews:

gdaladdo 00010.tif 2 4 8 18 32 64 128 256

Which takes 51 min and the file size goes to 2.6G.

This two step process takes a lot of disk and processing time. It would 
seem that this could be optimized if the warp and translate 
functionality where merged into a single command.

-Steve

On 7/1/2018 11:18 AM, 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.
>
> 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.
>
> -Steve
>
> On 7/1/2018 10:14 AM, Michael Smith wrote:
>> Steve,
>>
>> Setting that alpha channel makes it 4 bands. RGB + alpha channel. 
>> Either remove the ycbcr or the alpha channel.
>>
>> Michael Smith
>> Remote Sensing/GIS Center
>> US Army Corps of Engineers
>>
>>> On Jul 1, 2018, at 10:07 AM, Stephen Woodbridge 
>>> <stephenwoodbridge37 at gmail.com> wrote:
>>>
>>> Hi all,
>>>
>>> I'm trying to convert a utm jp2 file to a wgs84 tif file and getting 
>>> "ERROR 6: PHOTOMETRIC=YCBCR requires a source raster with only 3 
>>> bands (RGB)" but the src file has only 3 RBG bands.
>>>
>>> gdalwarp -t_srs EPSG:4326 -dstalpha -r bilinear -of GTiff -co 
>>> BIGTIFF=YES -co TILED=YES -co COMPRESS=JPEG -co JPEG_QUALITY=90 -co 
>>> PHOTOMETRIC=YCBCR '00010.jp2' 'tif/00010.tif'
>>>
>>> The command works if I remove -dstalpha so it seems that the error 
>>> message is erroneous and might need fixed. Regardless, I don't want 
>>> the transformed image to have black around it, so how do I do that?
>>>
>>> -Steve
>>>
>>> # gdalinfo 00010.jp2
>>> Driver: JP2OpenJPEG/JPEG-2000 driver based on OpenJPEG library
>>> Files: 00010.jp2
>>>         00010.jp2.aux.xml
>>> Size is 340668, 65335
>>> Coordinate System is:
>>> PROJCS["UTM_Zone_38_Northern_Hemisphere",
>>>      GEOGCS["GCS_WGS_1984",
>>>          DATUM["WGS84",
>>>              SPHEROID["WGS84",6378137,298.257223563]],
>>>          PRIMEM["Greenwich",0],
>>>          UNIT["Degree",0.017453292519943295]],
>>>      PROJECTION["Transverse_Mercator"],
>>>      PARAMETER["latitude_of_origin",0],
>>>      PARAMETER["central_meridian",45],
>>>      PARAMETER["scale_factor",0.9996],
>>>      PARAMETER["false_easting",500000],
>>>      PARAMETER["false_northing",0],
>>>      UNIT["Meter",1]]
>>> Origin = (265998.000000000000000,1848002.000000000000000)
>>> Pixel Size = (3.000000000000000,-3.000000000000000)
>>> Image Structure Metadata:
>>>    INTERLEAVE=PIXEL
>>> Corner Coordinates:
>>> Upper Left  (  265998.000, 1848002.000) ( 42d48'19.81"E, 16d42'11.25"N)
>>> Lower Left  (  265998.000, 1651997.000) ( 42d49'28.30"E, 14d55'56.73"N)
>>> Upper Right ( 1288002.000, 1848002.000) ( 52d22'11.02"E, 16d35' 0.58"N)
>>> Lower Right ( 1288002.000, 1651997.000) ( 52d18'23.31"E, 14d49'33.87"N)
>>> Center      (  777000.000, 1749999.500) ( 47d35' 9.06"E, 15d48'48.25"N)
>>> Band 1 Block=1024x1024 Type=Byte, ColorInterp=Red
>>>    Overviews: 170334x32667, 85167x16333, 42583x8166, 21291x4083, 
>>> 10645x2041
>>>    Overviews: arbitrary
>>>    Image Structure Metadata:
>>>      COMPRESSION=JPEG2000
>>> Band 2 Block=1024x1024 Type=Byte, ColorInterp=Green
>>>    Overviews: 170334x32667, 85167x16333, 42583x8166, 21291x4083, 
>>> 10645x2041
>>>    Overviews: arbitrary
>>>    Image Structure Metadata:
>>>      COMPRESSION=JPEG2000
>>> Band 3 Block=1024x1024 Type=Byte, ColorInterp=Blue
>>>    Overviews: 170334x32667, 85167x16333, 42583x8166, 21291x4083, 
>>> 10645x2041
>>>    Overviews: arbitrary
>>>    Image Structure Metadata:
>>>      COMPRESSION=JPEG2000
>>>
>>>
>>> ---
>>> This email has been checked for viruses by Avast antivirus software.
>>> https://www.avast.com/antivirus
>>>
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>



More information about the gdal-dev mailing list