Le 20/02/2024 à 11:15, Elena Ruiz via gdal-dev a écrit :
Hello, I have version 3.6.2 of GDAL and I need to crop an image using a contour from a GML file, so far there is no problem.

The problem begins when the original image is a GEOTIFF with transparency and it generates a cropped image, the information of both images is a little lower.

The color table changes from having 2 values to having 256, this causes it to lose transparency although it has the label "Mask Flags: PER_DATASET ALPHA" which indicates that it has an alpha channel.

My question is, why does the color table change?, and is there any parameter that can be used with gdalwarp or gdal_translate to avoid this and keep the image transparent?

Strictly speaking your input image has no transparency, just black & white colors. Not sure which one you interpret as transparent?


You could force a 1-bit output image (ie with a color palette of 2 colors) by adding -co NBITS=1 . But that will likely won't play well with -dstalpha.  You'd then want to use instead -dstnodata 0 if black is the transparent color or -dstnodata 1 if white is the transparent color


Even

--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to