How to create color table from multiband tiff file

23 views Asked by At

For context I am using gdal2tiles to convert tiff to tiles. Now I encountered an error where a color table is expected. Upon checking the file it has 3 bands. Is there a way to create a color table based on those 3 bands?

File info with 3 bands

Driver: GTiff/GeoTIFF
Files: ortho_stock.tif
Size is 2944, 5312
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 5312.0)
Upper Right ( 2944.0,    0.0)
Lower Right ( 2944.0, 5312.0)
Center      ( 1472.0, 2656.0)
Band 1 Block=2944x112 Type=Byte, ColorInterp=Red
Band 2 Block=2944x112 Type=Byte, ColorInterp=Green
Band 3 Block=2944x112 Type=Byte, ColorInterp=Blue

File info accepted file input

Files: low_res.tif
Size is 1842, 662
Coordinate System is:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.25722356049,
            LENGTHUNIT["metre",1,
                ID["EPSG",9001]]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433,
            ID["EPSG",9122]]],
    CS[ellipsoidal,2],
        AXIS["latitude",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433,
                ID["EPSG",9122]]],
        AXIS["longitude",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433,
                ID["EPSG",9122]]]]
Data axis to CRS axis mapping: 2,1
Origin = (140.744109347848337,42.806987488589783)
Pixel Size = (0.000001871700000,-0.000001871700000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=PACKBITS
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 140.7441093,  42.8069875) (140d44'38.79"E, 42d48'25.15"N)
Lower Left  ( 140.7441093,  42.8057484) (140d44'38.79"E, 42d48'20.69"N)
Upper Right ( 140.7475570,  42.8069875) (140d44'51.21"E, 42d48'25.15"N)
Lower Right ( 140.7475570,  42.8057484) (140d44'51.21"E, 42d48'20.69"N)
Center      ( 140.7458332,  42.8063680) (140d44'45.00"E, 42d48'22.92"N)
Band 1 Block=1842x1 Type=Byte, ColorInterp=Palette
  Color Table (RGB with 256 entries)
    0: 0,0,0,255
    1: 22,26,33,255
    2: 22,44,16,255
    3: 27,53,32,255
    4: 33,28,16,255
    5: 36,27,33,255
    6: 38,51,22,255
    7: 42,56,35,255
    8: 18,53,75,255
    ...
0

There are 0 answers