More

How to make transparent the Index 0 of the color table of a Tif/GTiff/GeoTiff using gdal?

How to make transparent the Index 0 of the color table of a Tif/GTiff/GeoTiff using gdal?


With a Tif file, I'm trying to generate tiles using gdal tools.

gdalinfo

gdalinfo I_III_IVA_MRA_WGS.tif | more

Output

Driver: GTiff/GeoTIFF Files: I_III_IVA_MRA_WGS.tif Size is 17119, 23309 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433], AUTHORITY["EPSG","4326"]] Origin = (119.423193410175510,18.468686780527399) Pixel Size = (0.000179663056824,-0.000188223140884) Metadata: AREA_OR_POINT=Area Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates: Upper Left ( 119.4231934, 18.4686868) (119d25'23.50"E, 18d28' 7.27"N) Lower Left ( 119.4231934, 14.0813936) (119d25'23.50"E, 14d 4'53.02"N) Upper Right ( 122.4988453, 18.4686868) (122d29'55.84"E, 18d28' 7.27"N) Lower Right ( 122.4988453, 14.0813936) (122d29'55.84"E, 14d 4'53.02"N) Center ( 120.9610193, 16.2750402) (120d57'39.67"E, 16d16'30.14"N) Band 1 Block=17119x1 Type=Byte, ColorInterp=Palette NoData Value=0 Color Table (RGB with 256 entries) 0: 255,255,255,255 1: 0,150,0,255 2: 0,0,0,255 3: 0,0,0,255 4: 0,0,0,255… 22: 0,0,0,255 -- More --

When I finally generate the tiles using gdal2tiles, it includes the canvass of the image.

My question is how can we make transparent the Index 0 of the color table of a Tif/GTiff/GeoTiff using gdal?


See gdalwarp command, especially-dstalpha,-srcnodataand-dstnodataflags.

In my case I usegdalwarp -dstnodata 255 -dstalpha src.tif dst.tif.


Watch the video: arcgis extract selected features. arcgis extract raster values