2

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.

enter image description here

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

2

See gdalwarp command, especially -dstalpha, -srcnodata and -dstnodata flags.

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

3
  • what does -dstnodata 255 mean? – Abel Melquiades Callejo Nov 10 '15 at 14:34
  • Pixels with value 255 will be considered no data. However, it seems that having value 255 in at least one of the bands is enough to mark pixel as nodata. Which I assume is not what you want. – Michal Zimmermann Nov 10 '15 at 15:08
  • Maybe also play with "gdalbuildvrt -srcnodata "0 0 0" outfile.vrt input.tif" and then convert the resulting VRT to TIFF – markusN Aug 4 '16 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.