6

I have a five bands geotiff file for Red, Green, Blue, Red-edge and Infra-red, and want to use gdal_translate to extract bands Red, Green and Blue

gdal_translate -b 1 -b 2 -b 3 -mask "none" "input.tif" "output.tif"

However, the generated file has the wrong colours (most of pointozs are blacks).

I guess it is related with colour range and ColorInterp is undefined. But I don't know how to fix them.

This is the gdalinfo for the original file:

Driver: GTiff/GeoTIFF
Files: input.tif
Size is 10458, 10825
Coordinate System is:
PROJCS["WGS 84 / UTM zone 56S",
    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"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",153],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",10000000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","32756"]]
Origin = (411260.815060000050000,6878637.363170000700000)
Pixel Size = (0.012419999999981,-0.012419999999981)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_SOFTWARE=MicaSense
Image Structure Metadata:
  COMPRESSION=DEFLATE
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  411260.815, 6878637.363) (152d 5'44.47"E, 28d12'54.39"S)
Lower Left  (  411260.815, 6878502.917) (152d 5'44.44"E, 28d12'58.76"S)
Upper Right (  411390.703, 6878637.363) (152d 5'49.24"E, 28d12'54.43"S)
Lower Right (  411390.703, 6878502.917) (152d 5'49.20"E, 28d12'58.79"S)
Center      (  411325.759, 6878570.140) (152d 5'46.84"E, 28d12'56.59"S)
Band 1 Block=10458x1 Type=UInt16, ColorInterp=Gray
  Min=0.000 Max=5454.000 
  Minimum=0.000, Maximum=5454.000, Mean=1036.637, StdDev=1083.467
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=5454
    STATISTICS_MEAN=1036.637087124
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=1083.4669493555
Band 2 Block=10458x1 Type=UInt16, ColorInterp=Undefined
  Min=0.000 Max=6616.000 
  Minimum=0.000, Maximum=6616.000, Mean=1332.553, StdDev=1386.218
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=6616
    STATISTICS_MEAN=1332.553257019
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=1386.2184173683
Band 3 Block=10458x1 Type=UInt16, ColorInterp=Undefined
  Min=0.000 Max=8943.000 
  Minimum=0.000, Maximum=8943.000, Mean=1594.110, StdDev=1699.603
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=8943
    STATISTICS_MEAN=1594.1095702538
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=1699.603238969
Band 4 Block=10458x1 Type=UInt16, ColorInterp=Undefined
  Min=0.000 Max=9650.000 
  Minimum=0.000, Maximum=9650.000, Mean=1924.547, StdDev=2032.229
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=9650
    STATISTICS_MEAN=1924.5465918094
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=2032.228987124
Band 5 Block=10458x1 Type=UInt16, ColorInterp=Undefined
  Min=0.000 Max=16783.000 
  Minimum=0.000, Maximum=16783.000, Mean=2732.010, StdDev=2919.037
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=16783
    STATISTICS_MEAN=2732.0096822665
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=2919.0373612217

This is the gdalinfo for output file:

Driver: GTiff/GeoTIFF
Files: output.tif
Size is 10458, 10825
Coordinate System is:
PROJCS["WGS 84 / UTM zone 56S",
    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"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",153],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",10000000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","32756"]]
Origin = (411260.815060000050000,6878637.363170000700000)
Pixel Size = (0.012419999999981,-0.012419999999981)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_SOFTWARE=MicaSense
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  411260.815, 6878637.363) (152d 5'44.47"E, 28d12'54.39"S)
Lower Left  (  411260.815, 6878502.917) (152d 5'44.44"E, 28d12'58.76"S)
Upper Right (  411390.703, 6878637.363) (152d 5'49.24"E, 28d12'54.43"S)
Lower Right (  411390.703, 6878502.917) (152d 5'49.20"E, 28d12'58.79"S)
Center      (  411325.759, 6878570.140) (152d 5'46.84"E, 28d12'56.59"S)
Band 1 Block=10458x1 Type=UInt16, ColorInterp=Gray
  Min=0.000 Max=5454.000 
  Minimum=0.000, Maximum=5454.000, Mean=1036.637, StdDev=1083.467
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=5454
    STATISTICS_MEAN=1036.637087124
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=1083.4669493555
Band 2 Block=10458x1 Type=UInt16, ColorInterp=Undefined
  Min=0.000 Max=6616.000 
  Minimum=0.000, Maximum=6616.000, Mean=1332.553, StdDev=1386.218
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=6616
    STATISTICS_MEAN=1332.553257019
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=1386.2184173683
Band 3 Block=10458x1 Type=UInt16, ColorInterp=Undefined
  Min=0.000 Max=8943.000 
  Minimum=0.000, Maximum=8943.000, Mean=1594.110, StdDev=1699.603
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=8943
    STATISTICS_MEAN=1594.1095702538
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=1699.603238969
1
  • Hi Bangyou, I see you are processing MicaSense data using GDAL. I'm trying to do the same. Could we talk about it, outside this forum?
    – Paul Meems
    Commented Nov 12, 2016 at 10:42

1 Answer 1

9

Your values aren't in 0,255 since they are UInt16. You can try rescaling to 0,255 (GDAL works it out by default from input min/max and output default 0,255):

gdal_translate -b 1 -b 2 -b 3 -mask "none" "input.tif" "output.tif" -scale

Note you can add params if the defaults aren't sensible:

-scale [src_min src_max [dst_min dst_max]]

http://www.gdal.org/gdal_translate.html

Note that you obviously will lose some information at this lower colour depth, and it may be better to simply use a different program for viewing, that doesn't assume 8-bit RGB.

1
  • I have the same problem, I guess QGIS and ArcGIS all assume 8-bit RGB. What software can viewing?
    – dorbodwolf
    Commented Jan 19, 2021 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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