ERROR 1: Error : band 1 has no color table












3














I would like to convert a GeoTIFF to PNG or JPEG RGB, and my GeoTIFF is stripped of a lot of valuable data (I think..)



I am on ubuntu and I am using gdal_translate to try and make a GeoTIFF turn into a regular PNG.



The GeoTIFF I have 'works'. I know because I can view it in QGIS on my Mac.



My GeoTIFF has 8 bands and I dont know which band corresponds to RGBA or what the other 4 bands stand for. It appears none of the bands have a valid 'color table'



  gdal_translate -of PNG test.tiff output.png


gives me



  ERROR 6: PNG driver doesn't support 8 bands.  Must be 1 (grey), 2 (grey+alpha), 3 (rgb) or 4 (rgba) bands.


When I try and just use any combination of bands for RGBA like this:



 gdal_translate -of PNG -b 1 -b 2 -b 3 test.tiff output.png


I just get a black image



In QGIS if I right click on my image and go to properties > Symbology, I see that the redband is band 1 (grey) (min 0, max 439, the green band is band 2 (min 0, max 460), the blue band is band 3 (min 0, max 454). and the image appears nicely in rgb - so the GeoTIFF 'works'.



I've also tried to make a gray image (even though I want an RGB), just because it looks like QGIS is saying band 1 is gray



  gdal_translate -of PNG -expand gray -b 1 test.tiff output.png


but that gives me



  ERROR 1: Error : band 1 has no color table


I dont really know what else to try, or if my image is black because I need to do something with 'scales' or something?



When I run tiffdump on my file I get



Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 8 (0x8) next 0 (0)
ImageWidth (256) SHORT (3) 1<2604>
ImageLength (257) SHORT (3) 1<2233>
BitsPerSample (258) SHORT (3) 8<16 16 16 16 16 16 16 16>
Compression (259) SHORT (3) 1<1>
Photometric (262) SHORT (3) 1<1>
StripOffsets (273) LONG (4) 2233<18288 59952 101616 143280 184944 226608 268272 309936 351600 393264 434928 476592 518256 559920 601584 643248 684912 726576 768240 809904 851568 893232 934896 976560 ...>
SamplesPerPixel (277) SHORT (3) 1<8>
RowsPerStrip (278) SHORT (3) 1<1>
StripByteCounts (279) LONG (4) 2233<41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 ...>
PlanarConfig (284) SHORT (3) 1<1>
ExtraSamples (338) SHORT (3) 7<0 0 0 0 0 0 0>
SampleFormat (339) SHORT (3) 8<1 1 1 1 1 1 1 1>
33550 (0x830e) DOUBLE (12) 3<2.20356e-06 2.20356e-06 0>
33922 (0x8482) DOUBLE (12) 6<0 0 0 -82.0121 27.3184 0>
34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 2 1025 0 1 1 2048 0 1 4326 2049 34737 7 0 2054 0 1 9102 ...>
34736 (0x87b0) DOUBLE (12) 2<298.257 6.37814e+06>
34737 (0x87b1) ASCII (2) 8<WGS 84|>


gdalinfo returns



Band 1 Block=2604x1 Type=UInt16, ColorInterp=Gray
Band 2 Block=2604x1 Type=UInt16, ColorInterp=Undefined
Band 3 Block=2604x1 Type=UInt16, ColorInterp=Undefined
Band 4 Block=2604x1 Type=UInt16, ColorInterp=Undefined
Band 5 Block=2604x1 Type=UInt16, ColorInterp=Undefined
Band 6 Block=2604x1 Type=UInt16, ColorInterp=Undefined
Band 7 Block=2604x1 Type=UInt16, ColorInterp=Undefined
Band 8 Block=2604x1 Type=UInt16, ColorInterp=Undefined









share|improve this question





























    3














    I would like to convert a GeoTIFF to PNG or JPEG RGB, and my GeoTIFF is stripped of a lot of valuable data (I think..)



    I am on ubuntu and I am using gdal_translate to try and make a GeoTIFF turn into a regular PNG.



    The GeoTIFF I have 'works'. I know because I can view it in QGIS on my Mac.



    My GeoTIFF has 8 bands and I dont know which band corresponds to RGBA or what the other 4 bands stand for. It appears none of the bands have a valid 'color table'



      gdal_translate -of PNG test.tiff output.png


    gives me



      ERROR 6: PNG driver doesn't support 8 bands.  Must be 1 (grey), 2 (grey+alpha), 3 (rgb) or 4 (rgba) bands.


    When I try and just use any combination of bands for RGBA like this:



     gdal_translate -of PNG -b 1 -b 2 -b 3 test.tiff output.png


    I just get a black image



    In QGIS if I right click on my image and go to properties > Symbology, I see that the redband is band 1 (grey) (min 0, max 439, the green band is band 2 (min 0, max 460), the blue band is band 3 (min 0, max 454). and the image appears nicely in rgb - so the GeoTIFF 'works'.



    I've also tried to make a gray image (even though I want an RGB), just because it looks like QGIS is saying band 1 is gray



      gdal_translate -of PNG -expand gray -b 1 test.tiff output.png


    but that gives me



      ERROR 1: Error : band 1 has no color table


    I dont really know what else to try, or if my image is black because I need to do something with 'scales' or something?



    When I run tiffdump on my file I get



    Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
    Directory 0: offset 8 (0x8) next 0 (0)
    ImageWidth (256) SHORT (3) 1<2604>
    ImageLength (257) SHORT (3) 1<2233>
    BitsPerSample (258) SHORT (3) 8<16 16 16 16 16 16 16 16>
    Compression (259) SHORT (3) 1<1>
    Photometric (262) SHORT (3) 1<1>
    StripOffsets (273) LONG (4) 2233<18288 59952 101616 143280 184944 226608 268272 309936 351600 393264 434928 476592 518256 559920 601584 643248 684912 726576 768240 809904 851568 893232 934896 976560 ...>
    SamplesPerPixel (277) SHORT (3) 1<8>
    RowsPerStrip (278) SHORT (3) 1<1>
    StripByteCounts (279) LONG (4) 2233<41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 ...>
    PlanarConfig (284) SHORT (3) 1<1>
    ExtraSamples (338) SHORT (3) 7<0 0 0 0 0 0 0>
    SampleFormat (339) SHORT (3) 8<1 1 1 1 1 1 1 1>
    33550 (0x830e) DOUBLE (12) 3<2.20356e-06 2.20356e-06 0>
    33922 (0x8482) DOUBLE (12) 6<0 0 0 -82.0121 27.3184 0>
    34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 2 1025 0 1 1 2048 0 1 4326 2049 34737 7 0 2054 0 1 9102 ...>
    34736 (0x87b0) DOUBLE (12) 2<298.257 6.37814e+06>
    34737 (0x87b1) ASCII (2) 8<WGS 84|>


    gdalinfo returns



    Band 1 Block=2604x1 Type=UInt16, ColorInterp=Gray
    Band 2 Block=2604x1 Type=UInt16, ColorInterp=Undefined
    Band 3 Block=2604x1 Type=UInt16, ColorInterp=Undefined
    Band 4 Block=2604x1 Type=UInt16, ColorInterp=Undefined
    Band 5 Block=2604x1 Type=UInt16, ColorInterp=Undefined
    Band 6 Block=2604x1 Type=UInt16, ColorInterp=Undefined
    Band 7 Block=2604x1 Type=UInt16, ColorInterp=Undefined
    Band 8 Block=2604x1 Type=UInt16, ColorInterp=Undefined









    share|improve this question



























      3












      3








      3


      1





      I would like to convert a GeoTIFF to PNG or JPEG RGB, and my GeoTIFF is stripped of a lot of valuable data (I think..)



      I am on ubuntu and I am using gdal_translate to try and make a GeoTIFF turn into a regular PNG.



      The GeoTIFF I have 'works'. I know because I can view it in QGIS on my Mac.



      My GeoTIFF has 8 bands and I dont know which band corresponds to RGBA or what the other 4 bands stand for. It appears none of the bands have a valid 'color table'



        gdal_translate -of PNG test.tiff output.png


      gives me



        ERROR 6: PNG driver doesn't support 8 bands.  Must be 1 (grey), 2 (grey+alpha), 3 (rgb) or 4 (rgba) bands.


      When I try and just use any combination of bands for RGBA like this:



       gdal_translate -of PNG -b 1 -b 2 -b 3 test.tiff output.png


      I just get a black image



      In QGIS if I right click on my image and go to properties > Symbology, I see that the redband is band 1 (grey) (min 0, max 439, the green band is band 2 (min 0, max 460), the blue band is band 3 (min 0, max 454). and the image appears nicely in rgb - so the GeoTIFF 'works'.



      I've also tried to make a gray image (even though I want an RGB), just because it looks like QGIS is saying band 1 is gray



        gdal_translate -of PNG -expand gray -b 1 test.tiff output.png


      but that gives me



        ERROR 1: Error : band 1 has no color table


      I dont really know what else to try, or if my image is black because I need to do something with 'scales' or something?



      When I run tiffdump on my file I get



      Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
      Directory 0: offset 8 (0x8) next 0 (0)
      ImageWidth (256) SHORT (3) 1<2604>
      ImageLength (257) SHORT (3) 1<2233>
      BitsPerSample (258) SHORT (3) 8<16 16 16 16 16 16 16 16>
      Compression (259) SHORT (3) 1<1>
      Photometric (262) SHORT (3) 1<1>
      StripOffsets (273) LONG (4) 2233<18288 59952 101616 143280 184944 226608 268272 309936 351600 393264 434928 476592 518256 559920 601584 643248 684912 726576 768240 809904 851568 893232 934896 976560 ...>
      SamplesPerPixel (277) SHORT (3) 1<8>
      RowsPerStrip (278) SHORT (3) 1<1>
      StripByteCounts (279) LONG (4) 2233<41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 ...>
      PlanarConfig (284) SHORT (3) 1<1>
      ExtraSamples (338) SHORT (3) 7<0 0 0 0 0 0 0>
      SampleFormat (339) SHORT (3) 8<1 1 1 1 1 1 1 1>
      33550 (0x830e) DOUBLE (12) 3<2.20356e-06 2.20356e-06 0>
      33922 (0x8482) DOUBLE (12) 6<0 0 0 -82.0121 27.3184 0>
      34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 2 1025 0 1 1 2048 0 1 4326 2049 34737 7 0 2054 0 1 9102 ...>
      34736 (0x87b0) DOUBLE (12) 2<298.257 6.37814e+06>
      34737 (0x87b1) ASCII (2) 8<WGS 84|>


      gdalinfo returns



      Band 1 Block=2604x1 Type=UInt16, ColorInterp=Gray
      Band 2 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 3 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 4 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 5 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 6 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 7 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 8 Block=2604x1 Type=UInt16, ColorInterp=Undefined









      share|improve this question















      I would like to convert a GeoTIFF to PNG or JPEG RGB, and my GeoTIFF is stripped of a lot of valuable data (I think..)



      I am on ubuntu and I am using gdal_translate to try and make a GeoTIFF turn into a regular PNG.



      The GeoTIFF I have 'works'. I know because I can view it in QGIS on my Mac.



      My GeoTIFF has 8 bands and I dont know which band corresponds to RGBA or what the other 4 bands stand for. It appears none of the bands have a valid 'color table'



        gdal_translate -of PNG test.tiff output.png


      gives me



        ERROR 6: PNG driver doesn't support 8 bands.  Must be 1 (grey), 2 (grey+alpha), 3 (rgb) or 4 (rgba) bands.


      When I try and just use any combination of bands for RGBA like this:



       gdal_translate -of PNG -b 1 -b 2 -b 3 test.tiff output.png


      I just get a black image



      In QGIS if I right click on my image and go to properties > Symbology, I see that the redband is band 1 (grey) (min 0, max 439, the green band is band 2 (min 0, max 460), the blue band is band 3 (min 0, max 454). and the image appears nicely in rgb - so the GeoTIFF 'works'.



      I've also tried to make a gray image (even though I want an RGB), just because it looks like QGIS is saying band 1 is gray



        gdal_translate -of PNG -expand gray -b 1 test.tiff output.png


      but that gives me



        ERROR 1: Error : band 1 has no color table


      I dont really know what else to try, or if my image is black because I need to do something with 'scales' or something?



      When I run tiffdump on my file I get



      Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
      Directory 0: offset 8 (0x8) next 0 (0)
      ImageWidth (256) SHORT (3) 1<2604>
      ImageLength (257) SHORT (3) 1<2233>
      BitsPerSample (258) SHORT (3) 8<16 16 16 16 16 16 16 16>
      Compression (259) SHORT (3) 1<1>
      Photometric (262) SHORT (3) 1<1>
      StripOffsets (273) LONG (4) 2233<18288 59952 101616 143280 184944 226608 268272 309936 351600 393264 434928 476592 518256 559920 601584 643248 684912 726576 768240 809904 851568 893232 934896 976560 ...>
      SamplesPerPixel (277) SHORT (3) 1<8>
      RowsPerStrip (278) SHORT (3) 1<1>
      StripByteCounts (279) LONG (4) 2233<41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 41664 ...>
      PlanarConfig (284) SHORT (3) 1<1>
      ExtraSamples (338) SHORT (3) 7<0 0 0 0 0 0 0>
      SampleFormat (339) SHORT (3) 8<1 1 1 1 1 1 1 1>
      33550 (0x830e) DOUBLE (12) 3<2.20356e-06 2.20356e-06 0>
      33922 (0x8482) DOUBLE (12) 6<0 0 0 -82.0121 27.3184 0>
      34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 2 1025 0 1 1 2048 0 1 4326 2049 34737 7 0 2054 0 1 9102 ...>
      34736 (0x87b0) DOUBLE (12) 2<298.257 6.37814e+06>
      34737 (0x87b1) ASCII (2) 8<WGS 84|>


      gdalinfo returns



      Band 1 Block=2604x1 Type=UInt16, ColorInterp=Gray
      Band 2 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 3 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 4 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 5 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 6 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 7 Block=2604x1 Type=UInt16, ColorInterp=Undefined
      Band 8 Block=2604x1 Type=UInt16, ColorInterp=Undefined






      qgis geotiff-tiff convert gdal-translate png






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 15 at 3:38









      Vince

      14.4k32647




      14.4k32647










      asked Dec 15 at 3:20









      user1709076

      1204




      1204






















          2 Answers
          2






          active

          oldest

          votes


















          4














          You can try to run a command with the options that handle the input bands in the best way possible and result in a well-constructed image similar to the one shown by qgis:



          gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none -colorinterp_1 red -colorinterp_2 green -colorinterp_3 blue test.tiff output.png




          UPDATE (based on comments):



          The answer works for GDAL >= 2.3.

          Previous versions of GDAL do not support the -colorinterp option.

          In that case, the solution is taking advantage of the PHOTOMETRIC=RGB creation option:



          gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB





          share|improve this answer























          • thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
            – user1709076
            Dec 15 at 11:45










          • Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
            – Gabriel De Luca
            Dec 15 at 12:01












          • thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
            – user1709076
            Dec 15 at 12:47










          • I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
            – user1709076
            Dec 15 at 12:54










          • I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
            – Gabriel De Luca
            Dec 15 at 13:02



















          3














          If the Geotiff has 8 bands, these don't have to be any colour reference. RGB has values between 0 and 255 for each band. So your data does not fit to RGB channels. Gray scales could be any range.



          It could also be that an undeclared NODATA value is fooling you.



          Either the metadata or the author of the file should reveal what the 8 bands are about. QGIS just makes a guess for RGB, but that does not have to be right.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "79"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f306115%2ferror-1-error-band-1-has-no-color-table%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            You can try to run a command with the options that handle the input bands in the best way possible and result in a well-constructed image similar to the one shown by qgis:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none -colorinterp_1 red -colorinterp_2 green -colorinterp_3 blue test.tiff output.png




            UPDATE (based on comments):



            The answer works for GDAL >= 2.3.

            Previous versions of GDAL do not support the -colorinterp option.

            In that case, the solution is taking advantage of the PHOTOMETRIC=RGB creation option:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB





            share|improve this answer























            • thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
              – user1709076
              Dec 15 at 11:45










            • Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
              – Gabriel De Luca
              Dec 15 at 12:01












            • thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
              – user1709076
              Dec 15 at 12:47










            • I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
              – user1709076
              Dec 15 at 12:54










            • I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
              – Gabriel De Luca
              Dec 15 at 13:02
















            4














            You can try to run a command with the options that handle the input bands in the best way possible and result in a well-constructed image similar to the one shown by qgis:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none -colorinterp_1 red -colorinterp_2 green -colorinterp_3 blue test.tiff output.png




            UPDATE (based on comments):



            The answer works for GDAL >= 2.3.

            Previous versions of GDAL do not support the -colorinterp option.

            In that case, the solution is taking advantage of the PHOTOMETRIC=RGB creation option:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB





            share|improve this answer























            • thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
              – user1709076
              Dec 15 at 11:45










            • Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
              – Gabriel De Luca
              Dec 15 at 12:01












            • thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
              – user1709076
              Dec 15 at 12:47










            • I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
              – user1709076
              Dec 15 at 12:54










            • I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
              – Gabriel De Luca
              Dec 15 at 13:02














            4












            4








            4






            You can try to run a command with the options that handle the input bands in the best way possible and result in a well-constructed image similar to the one shown by qgis:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none -colorinterp_1 red -colorinterp_2 green -colorinterp_3 blue test.tiff output.png




            UPDATE (based on comments):



            The answer works for GDAL >= 2.3.

            Previous versions of GDAL do not support the -colorinterp option.

            In that case, the solution is taking advantage of the PHOTOMETRIC=RGB creation option:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB





            share|improve this answer














            You can try to run a command with the options that handle the input bands in the best way possible and result in a well-constructed image similar to the one shown by qgis:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none -colorinterp_1 red -colorinterp_2 green -colorinterp_3 blue test.tiff output.png




            UPDATE (based on comments):



            The answer works for GDAL >= 2.3.

            Previous versions of GDAL do not support the -colorinterp option.

            In that case, the solution is taking advantage of the PHOTOMETRIC=RGB creation option:



            gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 15 at 15:57

























            answered Dec 15 at 8:15









            Gabriel De Luca

            3537




            3537












            • thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
              – user1709076
              Dec 15 at 11:45










            • Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
              – Gabriel De Luca
              Dec 15 at 12:01












            • thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
              – user1709076
              Dec 15 at 12:47










            • I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
              – user1709076
              Dec 15 at 12:54










            • I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
              – Gabriel De Luca
              Dec 15 at 13:02


















            • thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
              – user1709076
              Dec 15 at 11:45










            • Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
              – Gabriel De Luca
              Dec 15 at 12:01












            • thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
              – user1709076
              Dec 15 at 12:47










            • I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
              – user1709076
              Dec 15 at 12:54










            • I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
              – Gabriel De Luca
              Dec 15 at 13:02
















            thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
            – user1709076
            Dec 15 at 11:45




            thank you gabriel, unfortunately when i run this command, i get ERROR 6: Unknown option name '-colorinterp_1' i did gdal_translate --version and got GDAL 2.2.3, released 2017/11/20 so idk if that is a factor
            – user1709076
            Dec 15 at 11:45












            Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
            – Gabriel De Luca
            Dec 15 at 12:01






            Yes, the -colorinterp option is for GDAL >= 2.3, you can try with this creation option insted: gdal_translate -ot Byte -of PNG -b 1 -b 2 -b 3 -scale_1 0 439 -scale_2 0 460 -scale_3 0 454 -a_nodata none test.tiff output.png -co PHOTOMETRIC=RGB. I don't know how it works. Try it if you want instead of updating the library.
            – Gabriel De Luca
            Dec 15 at 12:01














            thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
            – user1709076
            Dec 15 at 12:47




            thanks gabriel. would you happen to know how i would upgrade to the latest version of gdal_translate ? I am on ubuntu 18.04. Unfortunately the alternative command gives me Warning 6: driver PNG does not support creation option PHOTOMETRIC and the image is black
            – user1709076
            Dec 15 at 12:47












            I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
            – user1709076
            Dec 15 at 12:54




            I tried doing sudo apt install libgdal-dev but gdal_translate --version still says GDAL 2.2.3, released 2017/11/20
            – user1709076
            Dec 15 at 12:54












            I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
            – Gabriel De Luca
            Dec 15 at 13:02




            I'm using the OSGeo4W Shell on Windows. For Ubuntu, if you are using the UbuntuGIS repositories, I'm seeing that you need to add the ubuntugis-unstable PPA to have the last version of gdal.
            – Gabriel De Luca
            Dec 15 at 13:02













            3














            If the Geotiff has 8 bands, these don't have to be any colour reference. RGB has values between 0 and 255 for each band. So your data does not fit to RGB channels. Gray scales could be any range.



            It could also be that an undeclared NODATA value is fooling you.



            Either the metadata or the author of the file should reveal what the 8 bands are about. QGIS just makes a guess for RGB, but that does not have to be right.






            share|improve this answer


























              3














              If the Geotiff has 8 bands, these don't have to be any colour reference. RGB has values between 0 and 255 for each band. So your data does not fit to RGB channels. Gray scales could be any range.



              It could also be that an undeclared NODATA value is fooling you.



              Either the metadata or the author of the file should reveal what the 8 bands are about. QGIS just makes a guess for RGB, but that does not have to be right.






              share|improve this answer
























                3












                3








                3






                If the Geotiff has 8 bands, these don't have to be any colour reference. RGB has values between 0 and 255 for each band. So your data does not fit to RGB channels. Gray scales could be any range.



                It could also be that an undeclared NODATA value is fooling you.



                Either the metadata or the author of the file should reveal what the 8 bands are about. QGIS just makes a guess for RGB, but that does not have to be right.






                share|improve this answer












                If the Geotiff has 8 bands, these don't have to be any colour reference. RGB has values between 0 and 255 for each band. So your data does not fit to RGB channels. Gray scales could be any range.



                It could also be that an undeclared NODATA value is fooling you.



                Either the metadata or the author of the file should reveal what the 8 bands are about. QGIS just makes a guess for RGB, but that does not have to be right.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 15 at 6:51









                AndreJ

                67.8k561121




                67.8k561121






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f306115%2ferror-1-error-band-1-has-no-color-table%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Morgemoulin

                    Scott Moir

                    Souastre