Heya fellow QGIS users

I have a TIFF file like
https://drive.switch.ch/index.php/s/bfvkWCM1P6pbJ5E/download that I want
to represent a black-and-white image with transparency. (Each pixel is
either opaque black, opaque white or fully transparent*.)

In the TIFF at hand, this is represented by a 1-byte-per-pixel band with
a 4-component (so presumably RGBA-)palette with (opaque) black and white
entries and another 1-byte-per-pixel band for alpha. gdalinfo output
looks like this:
> |Driver: GTiff/GeoTIFF Files: merged.tif Size is 28346, 47244
> Coordinate System is: PROJCS["CH1903 / LV03", GEOGCS["CH1903",
> DATUM["CH1903", SPHEROID["Bessel 1841",6377397.155,299.1528128,
> AUTHORITY["EPSG","7004"]], TOWGS84[674.374,15.056,405.346,0,0,0,0],
> AUTHORITY["EPSG","6149"]], PRIMEM["Greenwich",0,
> AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433,
> AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4149"]],
> PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],
> PARAMETER["latitude_of_center",46.95240555555556],
> PARAMETER["longitude_of_center",7.439583333333333],
> PARAMETER["azimuth",90], PARAMETER["rectified_grid_angle",90],
> PARAMETER["scale_factor",1], PARAMETER["false_easting",600000],
> PARAMETER["false_northing",200000], UNIT["metre",1,
> AUTHORITY["EPSG","9001"]], AXIS["Y",EAST], AXIS["X",NORTH],
> AUTHORITY["EPSG","21781"]] Origin =
> (672173.366739814984612,233935.800211683992529) Pixel Size =
> (0.105835038426470,-0.105835038426470) Metadata: AREA_OR_POINT=Area
> Image Structure Metadata: COMPRESSION=LZW INTERLEAVE=PIXEL Corner
> Coordinates: Upper Left ( 672173.367, 233935.800) ( 8d23'35.46"E,
> 47d15'13.47"N) Lower Left ( 672173.367, 228935.730) ( 8d23'32.57"E,
> 47d12'31.56"N) Upper Right ( 675173.367, 233935.800) ( 8d25'58.14"E,
> 47d15'12.27"N) Lower Right ( 675173.367, 228935.730) ( 8d25'55.13"E,
> 47d12'30.35"N) Center ( 673673.367, 231435.765) ( 8d24'45.32"E,
> 47d13'51.92"N) Band 1 Block=256x256 Type=Byte, ColorInterp=Palette
> Mask Flags: PER_DATASET ALPHA Color Table (RGB with 256 entries) 0:
> 255,255,255,255 1: 0,0,0,255 2: 0,0,0,255 3: 0,0,0,255 4: 0,0,0,255 5:
> 0,0,0,255 6: 0,0,0,255 7: 0,0,0,255 8: 0,0,0,255 9: 0,0,0,255 10:
> 0,0,0,255 11: 0,0,0,255 12: 0,0,0,255 13: 0,0,0,255 14: 0,0,0,255 15:
> 0,0,0,255 16: 0,0,0,255 17: 0,0,0,255 18: 0,0,0,255 19: 0,0,0,255 20:
> 0,0,0,255 21: 0,0,0,255 22: 0,0,0,255 23: 0,0,0,255 24: 0,0,0,255 25:
> 0,0,0,255 26: 0,0,0,255 27: 0,0,0,255 28: 0,0,0,255 29: 0,0,0,255 30:
> 0,0,0,255 31: 0,0,0,255 32: 0,0,0,255 33: 0,0,0,255 34: 0,0,0,255 35:
> 0,0,0,255 36: 0,0,0,255 37: 0,0,0,255 38: 0,0,0,255 39: 0,0,0,255 40:
> 0,0,0,255 41: 0,0,0,255 42: 0,0,0,255 43: 0,0,0,255 44: 0,0,0,255 45:
> 0,0,0,255 46: 0,0,0,255 47: 0,0,0,255 48: 0,0,0,255 49: 0,0,0,255 50:
> 0,0,0,255 51: 0,0,0,255 52: 0,0,0,255 53: 0,0,0,255 54: 0,0,0,255 55:
> 0,0,0,255 56: 0,0,0,255 57: 0,0,0,255 58: 0,0,0,255 59: 0,0,0,255 60:
> 0,0,0,255 61: 0,0,0,255 62: 0,0,0,255 63: 0,0,0,255 64: 0,0,0,255 65:
> 0,0,0,255 66: 0,0,0,255 67: 0,0,0,255 68: 0,0,0,255 69: 0,0,0,255 70:
> 0,0,0,255 71: 0,0,0,255 72: 0,0,0,255 73: 0,0,0,255 74: 0,0,0,255 75:
> 0,0,0,255 76: 0,0,0,255 77: 0,0,0,255 78: 0,0,0,255 79: 0,0,0,255 80:
> 0,0,0,255 81: 0,0,0,255 82: 0,0,0,255 83: 0,0,0,255 84: 0,0,0,255 85:
> 0,0,0,255 86: 0,0,0,255 87: 0,0,0,255 88: 0,0,0,255 89: 0,0,0,255 90:
> 0,0,0,255 91: 0,0,0,255 92: 0,0,0,255 93: 0,0,0,255 94: 0,0,0,255 95:
> 0,0,0,255 96: 0,0,0,255 97: 0,0,0,255 98: 0,0,0,255 99: 0,0,0,255 100:
> 0,0,0,255 101: 0,0,0,255 102: 0,0,0,255 103: 0,0,0,255 104: 0,0,0,255
> 105: 0,0,0,255 106: 0,0,0,255 107: 0,0,0,255 108: 0,0,0,255 109:
> 0,0,0,255 110: 0,0,0,255 111: 0,0,0,255 112: 0,0,0,255 113: 0,0,0,255
> 114: 0,0,0,255 115: 0,0,0,255 116: 0,0,0,255 117: 0,0,0,255 118:
> 0,0,0,255 119: 0,0,0,255 120: 0,0,0,255 121: 0,0,0,255 122: 0,0,0,255
> 123: 0,0,0,255 124: 0,0,0,255 125: 0,0,0,255 126: 0,0,0,255 127:
> 0,0,0,255 128: 0,0,0,255 129: 0,0,0,255 130: 0,0,0,255 131: 0,0,0,255
> 132: 0,0,0,255 133: 0,0,0,255 134: 0,0,0,255 135: 0,0,0,255 136:
> 0,0,0,255 137: 0,0,0,255 138: 0,0,0,255 139: 0,0,0,255 140: 0,0,0,255
> 141: 0,0,0,255 142: 0,0,0,255 143: 0,0,0,255 144: 0,0,0,255 145:
> 0,0,0,255 146: 0,0,0,255 147: 0,0,0,255 148: 0,0,0,255 149: 0,0,0,255
> 150: 0,0,0,255 151: 0,0,0,255 152: 0,0,0,255 153: 0,0,0,255 154:
> 0,0,0,255 155: 0,0,0,255 156: 0,0,0,255 157: 0,0,0,255 158: 0,0,0,255
> 159: 0,0,0,255 160: 0,0,0,255 161: 0,0,0,255 162: 0,0,0,255 163:
> 0,0,0,255 164: 0,0,0,255 165: 0,0,0,255 166: 0,0,0,255 167: 0,0,0,255
> 168: 0,0,0,255 169: 0,0,0,255 170: 0,0,0,255 171: 0,0,0,255 172:
> 0,0,0,255 173: 0,0,0,255 174: 0,0,0,255 175: 0,0,0,255 176: 0,0,0,255
> 177: 0,0,0,255 178: 0,0,0,255 179: 0,0,0,255 180: 0,0,0,255 181:
> 0,0,0,255 182: 0,0,0,255 183: 0,0,0,255 184: 0,0,0,255 185: 0,0,0,255
> 186: 0,0,0,255 187: 0,0,0,255 188: 0,0,0,255 189: 0,0,0,255 190:
> 0,0,0,255 191: 0,0,0,255 192: 0,0,0,255 193: 0,0,0,255 194: 0,0,0,255
> 195: 0,0,0,255 196: 0,0,0,255 197: 0,0,0,255 198: 0,0,0,255 199:
> 0,0,0,255 200: 0,0,0,255 201: 0,0,0,255 202: 0,0,0,255 203: 0,0,0,255
> 204: 0,0,0,255 205: 0,0,0,255 206: 0,0,0,255 207: 0,0,0,255 208:
> 0,0,0,255 209: 0,0,0,255 210: 0,0,0,255 211: 0,0,0,255 212: 0,0,0,255
> 213: 0,0,0,255 214: 0,0,0,255 215: 0,0,0,255 216: 0,0,0,255 217:
> 0,0,0,255 218: 0,0,0,255 219: 0,0,0,255 220: 0,0,0,255 221: 0,0,0,255
> 222: 0,0,0,255 223: 0,0,0,255 224: 0,0,0,255 225: 0,0,0,255 226:
> 0,0,0,255 227: 0,0,0,255 228: 0,0,0,255 229: 0,0,0,255 230: 0,0,0,255
> 231: 0,0,0,255 232: 0,0,0,255 233: 0,0,0,255 234: 0,0,0,255 235:
> 0,0,0,255 236: 0,0,0,255 237: 0,0,0,255 238: 0,0,0,255 239: 0,0,0,255
> 240: 0,0,0,255 241: 0,0,0,255 242: 0,0,0,255 243: 0,0,0,255 244:
> 0,0,0,255 245: 0,0,0,255 246: 0,0,0,255 247: 0,0,0,255 248: 0,0,0,255
> 249: 0,0,0,255 250: 0,0,0,255 251: 0,0,0,255 252: 0,0,0,255 253:
> 0,0,0,255 254: 0,0,0,255 255: 0,0,0,255 Band 2 Block=256x256
> Type=Byte, ColorInterp=Alpha |

When I drag-and-drop this file into QGIS (I tried 2.18 and 3 with
identical results) to add it as a raster layer, it is displayed in
bright green: https://i.stack.imgur.com/F6Op8.png

The automatically set display mode (to be found in the "style"
properties) is "multiband color". Only if I manually set this to
"paletted" is the TIFF displayed as intended:
https://i.stack.imgur.com/GNJGs.png

Other software (e.g. GIMP) displays the TIFF as intended without need
for manual color interpretation adjustment.

Is that a bug in QGIS or am I doing something wrong? If a TIFF like this
is valid (I've asked at https://gis.stackexchange.com/q/279584/51574
whether it is), it seems clear to me that a band with a palette should
default to be interpreted according to that palette and an alpha-band as
opacity/transparency, not as e.g. red and green channel.

Regards,
Raphael Das Gupta

------------------------------------------------------------------------
* the linked example image only contains fully opaque pixels but has the
same band structure as the real data that also has fully transparent pixels
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to