[gdal-dev] JPEG compressed COGs nodata

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Mon Jul 25 09:48:32 PDT 2022


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-bounces at lists.osgeo.org> On Behalf Of Travis Kirstine
Sent: July 22, 2022 9:04 AM
To: gdal dev <gdal-dev at lists.osgeo.org>
Subject: Re: [gdal-dev] JPEG compressed COGs nodata


You don't often get email from traviskirstine at gmail.com<mailto:traviskirstine at 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 <traviskirstine at gmail.com<mailto:traviskirstine at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220725/a03d6f99/attachment-0001.htm>


More information about the gdal-dev mailing list