Package org.gdal.gdal

Examples of org.gdal.gdal.ColorTable


      /*      Loop over bands.                                                */
      /* ==================================================================== */
      for (iBand = 0; iBand < hDataset.getRasterCount(); iBand++) {
        Double[] pass1 = new Double[1], pass2 = new Double[1];
        double[] adfCMinMax = new double[2];
        ColorTable hTable;

        hBand = hDataset.GetRasterBand(iBand + 1);

        /*if( bSample )
         {
         float[] afSample = new float[10000];
         int   nCount;

         nCount = hBand.GetRandomRasterSample( 10000, afSample );
         System.out.println( "Got " + nCount + " samples." );
         }*/

                                int[] blockXSize = new int[1];
                                int[] blockYSize = new int[1];
                                hBand.GetBlockSize(blockXSize, blockYSize);
        System.out.println("Band "
            + (iBand+1)
                                                + " Block="
                                                + blockXSize[0] + "x" + blockYSize[0]
            + " Type="
            + gdal.GetDataTypeName(hBand.getDataType())
            + ", ColorInterp="
            + gdal.GetColorInterpretationName(hBand
                .GetRasterColorInterpretation()));

        String hBandDesc = hBand.GetDescription();
        if (hBandDesc != null && hBandDesc.length() > 0)
          System.out.println("  Description = " + hBandDesc);

        hBand.GetMinimum(pass1);
        hBand.GetMaximum(pass2);
        if(pass1[0] != null || pass2[0] != null || bComputeMinMax) {
                                    System.out.print( "  " );
                                    if( pass1[0] != null )
                                        System.out.print( "Min=" + pass1[0] + " ");
                                    if( pass2[0] != null )
                                        System.out.print( "Max=" + pass2[0] + " ");
                               
                                    if( bComputeMinMax )
                                    {
                                        hBand.ComputeRasterMinMax(adfCMinMax, 0);
                                        System.out.print( "  Computed Min/Max=" + adfCMinMax[0]
              + "," + adfCMinMax[1]);
                                    }
                       
                                    System.out.print( "\n" );
        }

                                double dfMin[] = new double[1];
                                double dfMax[] = new double[1];
                                double dfMean[] = new double[1];
                                double dfStdDev[] = new double[1];
        if( hBand.GetStatistics( bApproxStats, bStats,
                                                         dfMin, dfMax, dfMean, dfStdDev ) == gdalconstConstants.CE_None )
        {
            System.out.println( "  Minimum=" + dfMin[0] + ", Maximum=" + dfMax[0] +
                                                        ", Mean=" + dfMean[0] + ", StdDev=" + dfStdDev[0] );
        }

                                if( bReportHistograms )
                                {
                                    int[][] panHistogram = new int[1][];
                                    int eErr = hBand.GetDefaultHistogram(dfMin, dfMax, panHistogram, true, new TermProgressCallback());
                                    if( eErr == gdalconstConstants.CE_None )
                                    {
                                        int iBucket;
                                        int nBucketCount = panHistogram[0].length;
                                        System.out.print( "  " + nBucketCount + " buckets from " +
                                                           dfMin[0] + " to " + dfMax[0] + ":\n  " );
                                        for( iBucket = 0; iBucket < nBucketCount; iBucket++ )
                                            System.out.print( panHistogram[0][iBucket] + " ");
                                        System.out.print( "\n" );
                                    }
                                }

                                if ( bComputeChecksum)
                                {
                                    System.out.println( "  Checksum=" + hBand.Checksum());
                                }

        hBand.GetNoDataValue(pass1);
        if(pass1[0] != null)
        {
          System.out.println("  NoData Value=" + pass1[0]);
        }

        if (hBand.GetOverviewCount() > 0) {
          int iOverview;

          System.out.print("  Overviews: ");
          for (iOverview = 0; iOverview < hBand.GetOverviewCount(); iOverview++) {
            Band hOverview;

            if (iOverview != 0)
              System.out.print(", ");

            hOverview = hBand.GetOverview(iOverview);
            System.out.print(hOverview.getXSize() + "x"
                + hOverview.getYSize());
          }
          System.out.print("\n");

                                        if ( bComputeChecksum)
                                        {
                                            System.out.print( "  Overviews checksum: " );
                                            for( iOverview = 0;
                                                iOverview < hBand.GetOverviewCount();
                                                iOverview++ )
                                            {
                                                Band  hOverview;
                           
                                                if( iOverview != 0 )
                                                    System.out.print( ", " );
                           
                                                hOverview = hBand.GetOverview(iOverview);
                                                System.out.print( hOverview.Checksum());
                                            }
                                            System.out.print( "\n" );
                                        }
        }

        if( hBand.HasArbitraryOverviews() )
        {
            System.out.println( "  Overviews: arbitrary" );
        }


                                int nMaskFlags = hBand.GetMaskFlags(  );
                                if( (nMaskFlags & (gdalconstConstants.GMF_NODATA|gdalconstConstants.GMF_ALL_VALID)) == 0 )
                                {
                                    Band hMaskBand = hBand.GetMaskBand() ;
                       
                                    System.out.print( "  Mask Flags: " );
                                    if( (nMaskFlags & gdalconstConstants.GMF_PER_DATASET) != 0 )
                                        System.out.print( "PER_DATASET " );
                                    if( (nMaskFlags & gdalconstConstants.GMF_ALPHA) != 0 )
                                        System.out.print( "ALPHA " );
                                    if( (nMaskFlags & gdalconstConstants.GMF_NODATA) != 0 )
                                        System.out.print( "NODATA " );
                                    if( (nMaskFlags & gdalconstConstants.GMF_ALL_VALID) != 0 )
                                        System.out.print( "ALL_VALID " );
                                    System.out.print( "\n" );
                       
                                    if( hMaskBand != null &&
                                        hMaskBand.GetOverviewCount() > 0 )
                                    {
                                        int    iOverview;
                       
                                        System.out.print( "  Overviews of mask band: " );
                                        for( iOverview = 0;
                                            iOverview < hMaskBand.GetOverviewCount();
                                            iOverview++ )
                                        {
                                            Band  hOverview;
                       
                                            if( iOverview != 0 )
                                                System.out.print( ", " );
                       
                                            hOverview = hMaskBand.GetOverview( iOverview );
                                            System.out.print(
                                                    hOverview.getXSize() + "x" +
                                                    hOverview.getYSize() );
                                        }
                                        System.out.print( "\n" );
                                    }
                                }
                               
        if( hBand.GetUnitType() != null && hBand.GetUnitType().length() > 0)
        {
             System.out.println( "  Unit Type: " + hBand.GetUnitType() );
        }

                                Vector papszCategories = hBand.GetRasterCategoryNames();
                                if (papszCategories.size() > 0)
                                {
                                    System.out.println( "  Categories:" );
                                    Enumeration eCategories = papszCategories.elements();
                                    i = 0;
            while (eCategories.hasMoreElements()) {
                                            System.out.println("    " + i + ": " + (String) eCategories.nextElement());
                                            i ++;
                                    }
                                }

        hBand.GetOffset(pass1);
        if(pass1[0] != null && pass1[0].doubleValue() != 0) {
          System.out.print("  Offset: " + pass1[0]);
        }
        hBand.GetScale(pass1);
        if(pass1[0] != null && pass1[0].doubleValue() != 1) {
          System.out.println(",   Scale:" + pass1[0]);
        }

        papszMetadata = hBand.GetMetadata_List("");
         if( bShowMetadata && papszMetadata.size() > 0 ) {
            Enumeration keys = papszMetadata.elements();
            System.out.println("  Metadata:");
            while (keys.hasMoreElements()) {
              System.out.println("    " + (String) keys.nextElement());
            }
         }
        if (hBand.GetRasterColorInterpretation() == gdalconstConstants.GCI_PaletteIndex
            && (hTable = hBand.GetRasterColorTable()) != null) {
          int count;

          System.out.println("  Color Table ("
              + gdal.GetPaletteInterpretationName(hTable
                  .GetPaletteInterpretation()) + " with "
              + hTable.GetCount() + " entries)");

                                        if (bShowColorTable)
                                        {
                                            for (count = 0; count < hTable.GetCount(); count++) {
                                                    System.out.println(" " + count + ": "
                                                                    + hTable.GetColorEntry(count));
                                            }
                                        }
        }

                                RasterAttributeTable rat = hBand.GetDefaultRAT();
View Full Code Here

TOP

Related Classes of org.gdal.gdal.ColorTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.