For those not wanting or needing to take the processing hit of running nearblack, use gdalwarp and -dstalpha to create the alpha channel, and use intermediate VRT to save space and more time. Something like this:
gdalwarp -srcnodata 0 -dstalpha -of vrt source.tif xx-interim.vrt gdal_translate -of COG {...} xx-interim.vrt final.tif -Matt From: gdal-dev <gdal-dev-boun...@lists.osgeo.org> On Behalf Of Travis Kirstine Sent: July 22, 2022 9:04 AM To: gdal dev <gdal-dev@lists.osgeo.org> Subject: Re: [gdal-dev] JPEG compressed COGs nodata You don't often get email from traviskirst...@gmail.com<mailto:traviskirst...@gmail.com>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> To answer my own question I believe the answer is that you need to create an alpha band when working with RGB datasets to have JPEG compressed COGs without compression artifacts in the nodata areas. Creating a internal mask on the source data may work as well but I haven't tried. # add a alpha band using the nearblack utility nearblack -setalpha rgb_nodata.tif -o rgba.tif # create the COG gdal_translate -of COG -co COMPRESS=JPEG -co TILING_SCHEME=GoogleMapsCompatible -co NUM_THREADS=ALL_CPUS -co BIGTIFF=YES rgba.tif cog.tif Regards On Tue, 19 Jul 2022 at 15:19, Travis Kirstine <traviskirst...@gmail.com<mailto:traviskirst...@gmail.com>> wrote: I've been trying to create a COG with JPEG compression with transparent nodata values without much success. Is this possible without creating a secondary mask? Any hints? Regards
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev