Package org.gdal.gdal

Class Band


  • public class Band
    extends MajorObject
    Class Band is an uninstanciable class providing various methods to access a single raster band (or channel).

    The Band class is a binding for the C++ GDALRasterBand class.

    Band objects are returned by methods from other classes, such as Dataset.GetRasterBand() Users of the Java bindings must be aware that the Java primitive types byte, short, int are signed types, whereas a few GDAL data types (GDT_Byte, GDT_UInt16 and GDT_UInt32) are unsigned. To read/write those data types, you may have to choose a "larger" type for example (short/GDT_Int16 for GDT_Byte, int/GDT_Int32 for GDT_UInt16, double/GDT_Float64 for GDT_UInt32), or use some tricks to hold unsigned values into signed data type. For example :

       byte[] byteArray = new byte[xsize * ysize];
       byte[] byteArray2 = new byte[xsize * ysize];
       band.ReadRaster(0, 0, xsize, ysize, gdalconst.GDT_Byte, byteArray);
       for(int j=0; j < ysize; j++)
       {
          for(int i=0; i < xsize; i++)
          {
              byte bVal = byteArray[j*xsize+i]; // ranging from -128 to 127
              int nVal = ((int)bVal) & 0xff; // remapped to range from 0 to 255
              int nVal2;
              if (nVal > threshold)
                  nVal2 = 255;
              else
                  nVal2 = 0;
              byte bVal2 = (nVal2 > 127) ? nVal2 - 256 : nVal2; // remapped to range from -128 to 127
              byteArray2[j*xsize+i] = bVal2;
          }
       }
       band2.WriteRaster(0, 0, xsize, ysize, gdalconst.GDT_Byte, byteArray2);
     
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void _EnablePixelTypeSignedByteWarning​(boolean b)  
      int AdviseRead​(int xoff, int yoff, int xsize, int ysize)  
      int AdviseRead​(int xoff, int yoff, int xsize, int ysize, SWIGTYPE_p_int buf_xsize)  
      int AdviseRead​(int xoff, int yoff, int xsize, int ysize, SWIGTYPE_p_int buf_xsize, SWIGTYPE_p_int buf_ysize)  
      int AdviseRead​(int xoff, int yoff, int xsize, int ysize, SWIGTYPE_p_int buf_xsize, SWIGTYPE_p_int buf_ysize, SWIGTYPE_p_int buf_type)  
      int AdviseRead​(int xoff, int yoff, int xsize, int ysize, SWIGTYPE_p_int buf_xsize, SWIGTYPE_p_int buf_ysize, SWIGTYPE_p_int buf_type, java.util.Vector options)  
      MDArray AsMDArray()  
      int Checksum()
      Compute checksum for while image.
      int Checksum​(int xoff, int yoff, int xsize, int ysize)
      Compute checksum for image region.
      void ComputeBandStats​(double[] meanAndStdDevArray)
      Compute mean and standard deviation values.
      void ComputeBandStats​(double[] meanAndStdDevArray, int samplestep)
      Compute mean and standard deviation values.
      void ComputeRasterMinMax​(double[] minMaxArray)
      Compute the min/max values for a band.
      void ComputeRasterMinMax​(double[] minMaxArray, int approx_ok)
      Compute the min/max values for a band.
      int ComputeStatistics​(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev)
      Compute image statistics.
      int ComputeStatistics​(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev, ProgressCallback callback)
      Compute image statistics.
      int CreateMaskBand​(int nFlags)
      Adds a mask band to the current band.
      void delete()
      Deprecated.
      Do not do anything...
      int DeleteNoDataValue()  
      int Fill​(double real_fill)
      Fill this band with a constant value.
      int Fill​(double real_fill, double imag_fill)
      Fill this band with a constant value.
      void FlushCache()
      Flush raster data cache.
      int GetBand()
      Fetch the band number.
      void GetBlockSize​(int[] pnBlockXSize, int[] pnBlockYSize)
      Fetch the "natural" block size of this band.
      int GetBlockXSize()
      Fetch the "natural" block width of this band
      int GetBlockYSize()
      Fetch the "natural" block height of this band
      java.util.Vector GetCategoryNames()
      Fetch the list of category names for this raster.
      int GetColorInterpretation()
      How should this band be interpreted as color?
      ColorTable GetColorTable()
      Fetch the color table associated with band.
      Dataset GetDataset()  
      int getDataType()
      Return the data type of the band.
      int GetDefaultHistogram​(double[] min_ret, double[] max_ret, int[][] histogram_ret)
      Fetch default raster histogram.
      int GetDefaultHistogram​(double[] min_ret, double[] max_ret, int[][] histogram_ret, boolean force)
      Fetch default raster histogram.
      int GetDefaultHistogram​(double[] min_ret, double[] max_ret, int[][] histogram_ret, boolean force, ProgressCallback callback)
      Fetch default raster histogram.
      RasterAttributeTable GetDefaultRAT()
      Fetch default Raster Attribute Table.
      int GetHistogram​(double min, double max, int[] histogram)
      Compute raster histogram.
      int GetHistogram​(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok)
      Compute raster histogram.
      int GetHistogram​(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok, ProgressCallback callback)
      Compute raster histogram.
      int GetHistogram​(int[] histogram)
      Compute raster histogram.
      Band GetMaskBand()
      Return the mask band associated with the band.
      int GetMaskFlags()
      Return the status flags of the mask band associated with the band.
      void GetMaximum​(java.lang.Double[] val)
      Fetch the maximum value for this band.
      void GetMinimum​(java.lang.Double[] val)
      Fetch the minimum value for this band.
      void GetNoDataValue​(java.lang.Double[] val)
      Fetch the no data value for this band.
      void GetOffset​(java.lang.Double[] val)
      Fetch the raster value offset.
      Band GetOverview​(int i)
      Fetch overview raster band object.
      int GetOverviewCount()
      Return the number of overview layers available.
      java.util.Vector GetRasterCategoryNames()
      Fetch the list of category names for this raster.
      int GetRasterColorInterpretation()
      How should this band be interpreted as color?
      ColorTable GetRasterColorTable()
      Fetch the color table associated with band.
      int GetRasterDataType()
      Return the data type of the band.
      void GetScale​(java.lang.Double[] val)
      Fetch the raster value scale.
      int GetStatistics​(boolean approx_ok, boolean force, double[] min, double[] max, double[] mean, double[] stddev)
      Fetch image statistics.
      int GetStatistics​(int approx_ok, int force, double[] min, double[] max, double[] mean, double[] stddev)
      Fetch image statistics.
      java.lang.String GetUnitType()
      Return raster unit type.
      int getXSize()
      Fetch XSize of raster.
      int GetXSize()
      Fetch XSize of raster.
      int getYSize()
      Fetch YSize of raster.
      int GetYSize()
      Fetch YSize of raster.
      boolean HasArbitraryOverviews()
      Check for arbitrary overviews.
      boolean IsMaskBand()  
      int ReadBlock_Direct​(int nXBlockOff, int nYBlockOff, java.nio.ByteBuffer nioBuffer)
      Read a block of image data efficiently.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, byte[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, double[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, float[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, byte[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, double[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, float[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, int[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, long[] regularArrayOut)  
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, long[] regularArrayOut, int nPixelSpace)  
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, long[] regularArrayOut, int nPixelSpace, int nLineSpace)  
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, long[] array)  
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, short[] array)
      Read a region of image data for this band.
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, long[] array)  
      int ReadRaster​(int xoff, int yoff, int xsize, int ysize, short[] array)
      Read a region of image data for this band.
      java.nio.ByteBuffer ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize)
      Read a region of image data for this band.
      java.nio.ByteBuffer ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_type)
      Read a region of image data for this band.
      java.nio.ByteBuffer ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type)
      Read a region of image data for this band.
      int ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer nioBuffer)
      Read a region of image data for this band.
      int ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer nioBuffer, int nPixelSpace, int nLineSpace)
      Read a region of image data for this band.
      int ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, java.nio.ByteBuffer nioBuffer)
      Read a region of image data for this band.
      int ReadRaster_Direct​(int xoff, int yoff, int xsize, int ysize, java.nio.ByteBuffer nioBuffer)
      Read a region of image data for this band.
      int SetCategoryNames​(java.util.Vector names)
      Set the category names for this band.
      int SetColorInterpretation​(int eColorInterp)
      Set color interpretation of a band.
      int SetColorTable​(ColorTable colorTable)
      Set the raster color table.
      int SetDefaultHistogram​(double min, double max, int[] histogram)
      Set default histogram
      int SetDefaultRAT​(RasterAttributeTable table)
      Set default Raster Attribute Table.
      int SetNoDataValue​(double nodataValue)
      Set the no data value for this band.
      int SetOffset​(double newoffset)
      Set scaling offset.
      int SetRasterCategoryNames​(java.util.Vector names)
      Set the category names for this band.
      int SetRasterColorInterpretation​(int eColorInterp)
      Set color interpretation of a band.
      int SetRasterColorTable​(ColorTable colorTable)
      Set the raster color table.
      int SetScale​(double newscale)
      Set scaling ratio.
      int SetStatistics​(double min, double max, double mean, double stddev)
      Set statistics on band.
      int SetUnitType​(java.lang.String newunittype)
      Set unit type.
      int WriteBlock_Direct​(int nXBlockOff, int nYBlockOff, java.nio.ByteBuffer nioBuffer)
      Write a block of image data efficiently.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, byte[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, double[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, float[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, byte[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, double[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, float[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, int[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, long[] regularArrayIn)  
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, long[] regularArrayIn, int nPixelSpace)  
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, long[] regularArrayIn, int nPixelSpace, int nLineSpace)  
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, long[] array)  
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, int buf_type, short[] array)
      Write a region of image data for this band.
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, long[] array)  
      int WriteRaster​(int xoff, int yoff, int xsize, int ysize, short[] array)
      Write a region of image data for this band.
      int WriteRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer nioBuffer)
      Write a region of image data for this band.
      int WriteRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer nioBuffer, int nPixelSpace, int nLineSpace)
      Write a region of image data for this band.
      int WriteRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, java.nio.ByteBuffer nioBuffer)
      Write a region of image data for this band.
      int WriteRaster_Direct​(int xoff, int yoff, int xsize, int ysize, int buf_type, java.nio.ByteBuffer nioBuffer)
      Write a region of image data for this band.
      int WriteRaster_Direct​(int xoff, int yoff, int xsize, int ysize, java.nio.ByteBuffer nioBuffer)
      Write a region of image data for this band.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • delete

        public void delete()
        Deprecated.
        Do not do anything...
        Overrides:
        delete in class MajorObject
      • GetXSize

        public int GetXSize()
        Fetch XSize of raster.
        Returns:
        the width in pixels of this band.
        Since:
        Java bindings 1.7.0
      • GetYSize

        public int GetYSize()
        Fetch YSize of raster.
        Returns:
        the height in pixels of this band.
        Since:
        Java bindings 1.7.0
      • GetRasterDataType

        public int GetRasterDataType()
        Return the data type of the band.

        A value such as gdalconst.GDT_Byte, gdalconst.GDT_Int16, ...

        Returns:
        the data type of the band.
        Since:
        Java bindings 1.7.0
      • Checksum

        public int Checksum()
        Compute checksum for while image.

        Computes a 16bit (0-65535) checksum from data on the raster band. Floating point data is converted to 32bit integer so decimal portions of such raster data will not affect the checksum. Real and Imaginary components of complex bands influence the result.

        Returns:
        Checksum value.
        Since:
        Java bindings 1.7.0
      • GetStatistics

        public int GetStatistics​(boolean approx_ok,
                                 boolean force,
                                 double[] min,
                                 double[] max,
                                 double[] mean,
                                 double[] stddev)
        Fetch image statistics.

        Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the approx_ok flag can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.

        If force is false results will only be returned if it can be done quickly (i.e. without scanning the data). If force is false and results cannot be returned efficiently, the method will return CE_Warning but no warning will have been issued. This is a non-standard use of the CE_Warning return value to indicate "nothing done".

        Note that file formats using PAM (Persistent Auxiliary Metadata) services will generally cache statistics in the .pam file allowing fast fetch after the first request.

        Parameters:
        approx_ok - If true statistics may be computed based on overviews or a subset of all tiles.
        force - If true statistics will only be returned if it can be done without rescanning the image.
        min - Allocated array of one double into which to load image minimum (may be null).
        max - Allocated array of one double into which to load image maximum (may be null).
        mean - Allocated array of one double into which to load image mean (may be null).
        stddev - Allocated array of one double into which to load image standard deviation (may be null).
        Returns:
        gdalconst.CE_None on success, gdalconst.CE_Warning if no values returned, gdalconst.CE_Failure if an error occurs.
        Since:
        Java bindings 1.7.0
      • ReadRaster

        public int ReadRaster​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              int buf_type,
                              long[] array)
      • ReadRaster

        public int ReadRaster​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              long[] array)
      • WriteRaster

        public int WriteRaster​(int xoff,
                               int yoff,
                               int xsize,
                               int ysize,
                               int buf_type,
                               long[] array)
      • WriteRaster

        public int WriteRaster​(int xoff,
                               int yoff,
                               int xsize,
                               int ysize,
                               long[] array)
      • getXSize

        public int getXSize()
        Fetch XSize of raster.
        Returns:
        the width in pixels of this band.
      • getYSize

        public int getYSize()
        Fetch YSize of raster.
        Returns:
        the height in pixels of this band.
      • getDataType

        public int getDataType()
        Return the data type of the band.

        A value such as gdalconst.GDT_Byte, gdalconst.GDT_Int16, ...

        Returns:
        the data type of the band.
      • GetDataset

        public Dataset GetDataset()
      • GetBand

        public int GetBand()
        Fetch the band number.

        This method returns the band that this Band object represents within its dataset. This method may return a value of 0 to indicate Band objects without an apparently relationship to a dataset, such as Band's serving as overviews.

        Returns:
        band number (1+) or 0 if the band number isn't known.
        Since:
        Java bindings 1.7.0
      • GetBlockSize

        public void GetBlockSize​(int[] pnBlockXSize,
                                 int[] pnBlockYSize)
        Fetch the "natural" block size of this band.

        GDAL contains a concept of the natural block size of rasters so that applications can organized data access efficiently for some file formats. The natural block size is the block size that is most efficient for accessing the format. For many formats this is simple a whole scanline in which case pnBlockXSize[0] is set to GetXSize(), and pnBlockXSize[1] is set to 1.

        However, for tiled images this will typically be the tile size.

        Note that the X and Y block sizes don't have to divide the image size evenly, meaning that right and bottom edge blocks may be incomplete. See ReadBlock_Direct() for an example of code dealing with these issues.

        Parameters:
        pnBlockXSize - allocated array of 1 integer to put the X block size into or null.
        pnBlockYSize - allocated array of 1 integer to put the Y block size into or null.
      • GetColorInterpretation

        public int GetColorInterpretation()
        How should this band be interpreted as color?

        gdalconst.GCI_Undefined is returned when the format doesn't know anything about the color interpretation.

        Returns:
        color interpretation value for band.
        Since:
        Java bindings 1.7.0
      • GetRasterColorInterpretation

        public int GetRasterColorInterpretation()
        How should this band be interpreted as color?

        gdalconst.GCI_Undefined is returned when the format doesn't know anything about the color interpretation.

        Returns:
        color interpretation value for band.
      • SetColorInterpretation

        public int SetColorInterpretation​(int eColorInterp)
        Set color interpretation of a band.
        Parameters:
        eColorInterp - the new color interpretation to apply to this band.
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure if method is unsupported by format.
        Since:
        Java bindings 1.7.0
      • SetRasterColorInterpretation

        public int SetRasterColorInterpretation​(int eColorInterp)
        Set color interpretation of a band.
        Parameters:
        eColorInterp - the new color interpretation to apply to this band.
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure if method is unsupported by format.
      • GetNoDataValue

        public void GetNoDataValue​(java.lang.Double[] val)
        Fetch the no data value for this band.

        The no data value for a band is generally a special marker value used to mark pixels that are not valid data. Such pixels should generally not be displayed, nor contribute to analysis operations.

        Parameters:
        val - empty allocated array of type Double[] of size 1. val[0] will contain a Double object with the no data value if available, other val[0] will contain null
      • SetNoDataValue

        public int SetNoDataValue​(double nodataValue)
        Set the no data value for this band.

        To clear the nodata value, just set it with an "out of range" value. Complex band no data values must have an imagery component of zero.

        Parameters:
        nodataValue - the value to set.
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure on failure. If unsupported by the driver, CE_Failure is returned by no error message will have been emitted.
      • DeleteNoDataValue

        public int DeleteNoDataValue()
      • GetUnitType

        public java.lang.String GetUnitType()
        Return raster unit type.

        Return a name for the units of this raster's values. For instance, it might be "m" for an elevation model in meters, or "ft" for feet. If no units are available, a value of "" will be returned.

        Returns:
        unit name string.
        Since:
        Java bindings 1.7.0
      • SetUnitType

        public int SetUnitType​(java.lang.String newunittype)
        Set unit type.

        Set the unit type for a raster band. Values should be one of "" (the default indicating it is unknown), "m" indicating meters, or "ft" indicating feet, though other nonstandard values are allowed.

        Parameters:
        newunittype - the new unit type value.
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure if not succuessful, or unsupported.
        Since:
        Java bindings 1.8.0
      • GetRasterCategoryNames

        public java.util.Vector GetRasterCategoryNames()
        Fetch the list of category names for this raster.

        Raster values without associated names will have an empty string in the returned list. The first entry in the list is for raster values of zero, and so on.

        Returns:
        vector of names, or null if none.
      • SetRasterCategoryNames

        public int SetRasterCategoryNames​(java.util.Vector names)
        Set the category names for this band.

        See the GetCategoryNames() method for more on the interpretation of category names.

        Parameters:
        names - a vector of strings with category names. May be ,ull to just clear the existing list.
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure on failure. If unsupported by the driver, CE_Failure is returned by no error message will have been emitted.
      • GetMinimum

        public void GetMinimum​(java.lang.Double[] val)
        Fetch the minimum value for this band.

        For file formats that don't know this intrinsically, no value will be returned

        Parameters:
        val - empty allocated array of type Double[] of size 1. val[0] will contain a Double object with the minimum value if available, other val[0] will contain null
      • GetMaximum

        public void GetMaximum​(java.lang.Double[] val)
        Fetch the maximum value for this band.

        For file formats that don't know this intrinsically, no value will be returned

        Parameters:
        val - empty allocated array of type Double[] of size 1. val[0] will contain a Double object with the maximum value if available, other val[0] will contain null
      • GetOffset

        public void GetOffset​(java.lang.Double[] val)
        Fetch the raster value offset.

        This value (in combination with the GetScale() value) is used to transform raw pixel values into the units returned by GetUnits(). For example this might be used to store elevations in GUInt16 bands with a precision of 0.1, and starting from -100.

        Units value = (raw value * scale) + offset

        For file formats that don't know this intrinsically, no value will be returned

        Parameters:
        val - empty allocated array of type Double[] of size 1. val[0] will contain a Double object with the offset value if available, other val[0] will contain null
      • GetScale

        public void GetScale​(java.lang.Double[] val)
        Fetch the raster value scale.

        This value (in combination with the GetOffset() value) is used to transform raw pixel values into the units returned by GetUnits(). For example this might be used to store elevations in GUInt16 bands with a precision of 0.1, and starting from -100.

        Units value = (raw value * scale) + offset

        For file formats that don't know this intrinsically, no value will be returned

        Parameters:
        val - empty allocated array of type Double[] of size 1. val[0] will contain a Double object with the scale value if available, other val[0] will contain null
      • SetOffset

        public int SetOffset​(double newoffset)
        Set scaling offset.

        Very few formats implement this method. When not implemented it will issue a CPLE_NotSupported error and return CE_Failure.

        Parameters:
        newoffset - the new offset.
        Returns:
        gdalconst.CE_None or success or gdalconst.CE_Failure on failure.
        Since:
        Java bindings 1.8.0
      • SetScale

        public int SetScale​(double newscale)
        Set scaling ratio.

        Very few formats implement this method. When not implemented it will issue a CPLE_NotSupported error and return CE_Failure.

        Parameters:
        newscale - the new scale.
        Returns:
        gdalconst.CE_None or success or gdalconst.CE_Failure on failure.
        Since:
        Java bindings 1.8.0
      • ComputeStatistics

        public int ComputeStatistics​(boolean approx_ok,
                                     double[] min,
                                     double[] max,
                                     double[] mean,
                                     double[] stddev,
                                     ProgressCallback callback)
        Compute image statistics.

        Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the approx_ok flag can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.

        Once computed, the statistics will generally be "set" back on the raster band using SetStatistics().

        Parameters:
        approx_ok - If true statistics may be computed based on overviews or a subset of all tiles.
        min - Allocated array of one double into which to load image minimum (may be null).
        max - Allocated array of one double into which to load image maximum (may be null).
        mean - Allocated array of one double into which to load image mean (may be null).
        stddev - Allocated array of one double into which to load image standard deviation (may be null).
        callback - for reporting algorithm progress. May be null
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure if an error occurs or processing is terminated by the user.
        Since:
        Java bindings 1.7.0
      • SetStatistics

        public int SetStatistics​(double min,
                                 double max,
                                 double mean,
                                 double stddev)
        Set statistics on band.

        This method can be used to store min/max/mean/standard deviation statistics on a raster band.

        The default implementation stores them as metadata, and will only work on formats that can save arbitrary metadata. This method cannot detect whether metadata will be properly saved and so may return CE_None even if the statistics will never be saved.

        Parameters:
        min - minimum pixel value.
        max - maximum pixel value.
        mean - mean (average) of all pixel values.
        stddev - Standard deviation of all pixel values.
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure on failure.
      • GetOverviewCount

        public int GetOverviewCount()
        Return the number of overview layers available.
        Returns:
        overview count, zero if none.
      • GetOverview

        public Band GetOverview​(int i)
        Fetch overview raster band object.
        Parameters:
        i - overview index between 0 and GetOverviewCount()-1.
        Returns:
        overview Band.
      • Checksum

        public int Checksum​(int xoff,
                            int yoff,
                            int xsize,
                            int ysize)
        Compute checksum for image region.

        Computes a 16bit (0-65535) checksum from a region of raster data on the raster band. Floating point data is converted to 32bit integer so decimal portions of such raster data will not affect the checksum. Real and Imaginary components of complex bands influence the result.

        Parameters:
        xoff - pixel offset of window to read.
        yoff - line offset of window to read.
        xsize - pixel size of window to read.
        ysize - line size of window to read.
        Returns:
        Checksum value.
      • ComputeRasterMinMax

        public void ComputeRasterMinMax​(double[] minMaxArray,
                                        int approx_ok)
        Compute the min/max values for a band.

        If approximate is OK, then the band's GetMinimum()/GetMaximum() will be trusted. If it doesn't work, a subsample of blocks will be read to get an approximate min/max. If the band has a nodata value it will be excluded from the minimum and maximum.

        If approx_ok is 0, then all pixels will be read and used to compute an exact range.

        Parameters:
        minMaxArray - the allocated array of 2 doubles in which the minimum (minMaxArray[0]) and the maximum (minMaxArray[1]) are returned.
        approx_ok - 1 if an approximate (faster) answer is OK, otherwise 0.
      • ComputeBandStats

        public void ComputeBandStats​(double[] meanAndStdDevArray,
                                     int samplestep)
        Compute mean and standard deviation values.
        Parameters:
        meanAndStdDevArray - the allocated array of 2 doubles in which the mean value (meanAndStdDevArray[0]) and the standard deviation (meanAndStdDevArray[1]) are returned
        samplestep - step in number of lines
      • Fill

        public int Fill​(double real_fill,
                        double imag_fill)
        Fill this band with a constant value.

        GDAL makes no guarantees about what values pixels in newly created files are set to, so this method can be used to clear a band to a specified "default" value. The fill value is passed in as a double but this will be converted to the underlying type before writing to the file. An optional second argument allows the imaginary component of a complex constant value to be specified.

        Parameters:
        real_fill - Real component of fill value
        imag_fill - Imaginary component of fill value, defaults to zero
        Returns:
        gdalconst.CE_Failure if the write fails, otherwise gdalconst.CE_None
      • FlushCache

        public void FlushCache()
        Flush raster data cache.

        This call will recover memory used to cache data blocks for this raster band, and ensure that new requests are referred to the underlying driver.

      • GetRasterColorTable

        public ColorTable GetRasterColorTable()
        Fetch the color table associated with band.

        If there is no associated color table, the return result is null. The returned color table remains owned by the Band object. It should not be modified by the caller.

        Returns:
        color table, or null.
      • GetColorTable

        public ColorTable GetColorTable()
        Fetch the color table associated with band.

        If there is no associated color table, the return result is null. The returned color table remains owned by the Band object. It should not be modified by the caller.

        Returns:
        color table, or null.
      • SetRasterColorTable

        public int SetRasterColorTable​(ColorTable colorTable)
        Set the raster color table.
        Parameters:
        colorTable - the color table to apply. This may be null to clear the color table (where supported).
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure on failure. If the action is unsupported by the driver, a value of CE_Failure is returned, but no error is issued.
      • SetColorTable

        public int SetColorTable​(ColorTable colorTable)
        Set the raster color table.
        Parameters:
        colorTable - the color table to apply. This may be null to clear the color table (where supported).
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure on failure. If the action is unsupported by the driver, a value of CE_Failure is returned, but no error is issued.
      • GetDefaultRAT

        public RasterAttributeTable GetDefaultRAT()
        Fetch default Raster Attribute Table.

        A RAT will be returned if there is a default one associated with the band, otherwise null is returned. The returned RAT is owned by the band and should not be altered by the application.

        Returns:
        a RAT or null
      • SetDefaultRAT

        public int SetDefaultRAT​(RasterAttributeTable table)
        Set default Raster Attribute Table.

        Associates a default RAT with the band. If not implemented for the format a CPLE_NotSupported error will be issued.

        Parameters:
        table - the RAT to assign to the band.
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure if unsupported or otherwise failing.
      • GetMaskBand

        public Band GetMaskBand()
        Return the mask band associated with the band.

        The GDALRasterBand class includes a default implementation of GetMaskBand() that returns one of four default implementations :

        • If a corresponding .msk file exists it will be used for the mask band.
        • If the dataset has a NODATA_VALUES metadata item, an instance of the new GDALNoDataValuesMaskBand class will be returned. GetMaskFlags() will return GMF_NODATA | GMF_PER_DATASET. @since GDAL 1.6.0
        • If the band has a nodata value set, an instance of the new GDALNodataMaskRasterBand class will be returned. GetMaskFlags() will return GMF_NODATA.
        • If there is no nodata value, but the dataset has an alpha band that seems to apply to this band (specific rules yet to be determined) and that is of type GDT_Byte then that alpha band will be returned, and the flags GMF_PER_DATASET and GMF_ALPHA will be returned in the flags.
        • If neither of the above apply, an instance of the new GDALAllValidRasterBand class will be returned that has 255 values for all pixels. The null flags will return GMF_ALL_VALID.

        Note that the GetMaskBand() should always return a GDALRasterBand mask, even if it is only an all 255 mask with the flags indicating GMF_ALL_VALID.

        Returns:
        a valid mask band.
        Since:
        GDAL 1.5.0
        See Also:
        RFC 15 - No data bit mask
      • GetMaskFlags

        public int GetMaskFlags()
        Return the status flags of the mask band associated with the band.

        The GetMaskFlags() method returns an bitwise OR-ed set of status flags with the following available definitions that may be extended in the future:

        • GMF_ALL_VALID(0x01): There are no invalid pixels, all mask values will be 255. When used this will normally be the only flag set.
        • GMF_PER_DATASET(0x02): The mask band is shared between all bands on the dataset.
        • GMF_ALPHA(0x04): The mask band is actually an alpha band and may have values other than 0 and 255.
        • GMF_NODATA(0x08): Indicates the mask is actually being generated from nodata values. (mutually exclusive of GMF_ALPHA)

        The GDALRasterBand class includes a default implementation of GetMaskBand() that returns one of four default implementations :

        • If a corresponding .msk file exists it will be used for the mask band.
        • If the dataset has a NODATA_VALUES metadata item, an instance of the new GDALNoDataValuesMaskBand class will be returned. GetMaskFlags() will return GMF_NODATA | GMF_PER_DATASET. @since GDAL 1.6.0
        • If the band has a nodata value set, an instance of the new GDALNodataMaskRasterBand class will be returned. GetMaskFlags() will return GMF_NODATA.
        • If there is no nodata value, but the dataset has an alpha band that seems to apply to this band (specific rules yet to be determined) and that is of type GDT_Byte then that alpha band will be returned, and the flags GMF_PER_DATASET and GMF_ALPHA will be returned in the flags.
        • If neither of the above apply, an instance of the new GDALAllValidRasterBand class will be returned that has 255 values for all pixels. The null flags will return GMF_ALL_VALID.
        Returns:
        a valid mask band.
        Since:
        GDAL 1.5.0
        See Also:
        RFC 15 - No data bit mask
      • CreateMaskBand

        public int CreateMaskBand​(int nFlags)
        Adds a mask band to the current band.

        The default implementation of the CreateMaskBand() method is implemented based on similar rules to the .ovr handling implemented using the GDALDefaultOverviews object. A TIFF file with the extension .msk will be created with the same basename as the original file, and it will have as many bands as the original image (or just one for GMF_PER_DATASET). The mask images will be deflate compressed tiled images with the same block size as the original image if possible.

        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure on an error.
        Since:
        GDAL 1.5.0
        See Also:
        RFC 15 - No data bit mask
      • IsMaskBand

        public boolean IsMaskBand()
      • SetDefaultHistogram

        public int SetDefaultHistogram​(double min,
                                       double max,
                                       int[] histogram)
        Set default histogram
        Since:
        Java bindings 1.7.0
      • HasArbitraryOverviews

        public boolean HasArbitraryOverviews()
        Check for arbitrary overviews.

        This returns true if the underlying datastore can compute arbitrary overviews efficiently, such as is the case with OGDI over a network. Datastores with arbitrary overviews don't generally have any fixed overviews, but the ReadRaster() method can be used in downsampling mode to get overview data efficiently.

        Returns:
        true if arbitrary overviews available (efficiently), otherwise false.
        Since:
        Java bindings 1.7.0
      • GetCategoryNames

        public java.util.Vector GetCategoryNames()
        Fetch the list of category names for this raster.

        Raster values without associated names will have an empty string in the returned list. The first entry in the list is for raster values of zero, and so on.

        Returns:
        vector of names, or null if none.
        Since:
        GDAL 1.9.0
      • SetCategoryNames

        public int SetCategoryNames​(java.util.Vector names)
        Set the category names for this band.

        See the GetCategoryNames() method for more on the interpretation of category names.

        Parameters:
        names - a vector of strings with category names. May be ,ull to just clear the existing list.
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure on failure. If unsupported by the driver, CE_Failure is returned by no error message will have been emitted.
        Since:
        GDAL 1.9.0
      • AdviseRead

        public int AdviseRead​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              SWIGTYPE_p_int buf_xsize)
      • AdviseRead

        public int AdviseRead​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize)
      • AsMDArray

        public MDArray AsMDArray()
      • _EnablePixelTypeSignedByteWarning

        public void _EnablePixelTypeSignedByteWarning​(boolean b)
      • ReadRaster_Direct

        public int ReadRaster_Direct​(int xoff,
                                     int yoff,
                                     int xsize,
                                     int ysize,
                                     int buf_xsize,
                                     int buf_ysize,
                                     int buf_type,
                                     java.nio.ByteBuffer nioBuffer,
                                     int nPixelSpace,
                                     int nLineSpace)
        Read a region of image data for this band.

        This method allows reading a region of a GDALRasterBand into a buffer. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).

        The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.

        Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.

        For highest performance full resolution data access, read on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the ReadBlock(int, int, java.nio.ByteBuffer) method.

        When requesting a multi-byte datatype (GDT_Int16, GDT_Int32, GDT_Float32, ...), you should generally set the byte order of the buffer to the native order of the machine with nioBuffer.order(ByteOrder.nativeOrder()) (the default is BIG_ENDIAN) if you use the getShort(), getInt(), getFloat() etc... methods of the ByteBuffer class.

        Parameters:
        xoff - The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
        yoff - The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
        xsize - The width of the region of the band to be accessed in pixels.
        ysize - The height of the region of the band to be accessed in lines.
        buf_xsize - the width of the buffer image into which the desired region is to be read, or from which it is to be written.
        buf_ysize - the height of the buffer image into which the desired region is to be read, or from which it is to be written.
        buf_type - the type of the pixel values in the nioBuffer data buffer. One of gdalconstConstants.GDT_Byte, gdalconstConstants.GDT_Int16, ... The pixel values will automatically be translated to/from the GDALRasterBand data type as needed.
        nioBuffer - The buffer into which the data should be read. This buffer must contain at least buf_xsize * buf_ysize words of type buf_type. It is organized in left to right, top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters.
        nPixelSpace - The byte offset from the start of one pixel value in the buffer to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype buf_type is used.
        nLineSpace - The byte offset from the start of one scanline in the buffer to the start of the next. If defaulted the size of the datatype buf_type * buf_xsize is used.
        Returns:
        CE_Failure if the access fails, otherwise CE_None.
        Since:
        Java bindings 1.7.0
      • ReadRaster

        public int ReadRaster​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              int buf_xsize,
                              int buf_ysize,
                              int buf_type,
                              byte[] array,
                              int nPixelSpace,
                              int nLineSpace)
        Read a region of image data for this band.

        This method allows reading a region of a GDALRasterBand into a buffer. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).

        The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.

        Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.

        For highest performance full resolution data access, read on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the ReadBlock(int, int, java.nio.ByteBuffer) method.

        Parameters:
        xoff - The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
        yoff - The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
        xsize - The width of the region of the band to be accessed in pixels.
        ysize - The height of the region of the band to be accessed in lines.
        buf_xsize - the width of the buffer image into which the desired region is to be read, or from which it is to be written.
        buf_ysize - the height of the buffer image into which the desired region is to be read, or from which it is to be written.
        buf_type - the type of the pixel values in the array. One of gdalconstConstants.GDT_Byte, gdalconstConstants.GDT_Int16, ... The pixel values will automatically be translated to/from the Band data type as needed. The GDAL type must be consistent with the type of the Java array.
        array - The buffer into which the data should be read. This buffer must contain at least buf_xsize * buf_ysize words of type buf_type. It is organized in left to right, top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters.
        nPixelSpace - The byte offset from the start of one pixel value in the buffer to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype buf_type is used.
        nLineSpace - The byte offset from the start of one scanline in the buffer to the start of the next. If defaulted the size of the datatype buf_type * buf_xsize is used.
        Returns:
        CE_Failure if the access fails, otherwise CE_None.
        Since:
        Java bindings 1.7.0
      • ReadRaster

        public int ReadRaster​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              int buf_xsize,
                              int buf_ysize,
                              int buf_type,
                              long[] regularArrayOut,
                              int nPixelSpace,
                              int nLineSpace)
      • ReadRaster

        public int ReadRaster​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              int buf_xsize,
                              int buf_ysize,
                              int buf_type,
                              long[] regularArrayOut,
                              int nPixelSpace)
      • ReadRaster

        public int ReadRaster​(int xoff,
                              int yoff,
                              int xsize,
                              int ysize,
                              int buf_xsize,
                              int buf_ysize,
                              int buf_type,
                              long[] regularArrayOut)
      • WriteRaster_Direct

        public int WriteRaster_Direct​(int xoff,
                                      int yoff,
                                      int xsize,
                                      int ysize,
                                      int buf_xsize,
                                      int buf_ysize,
                                      int buf_type,
                                      java.nio.ByteBuffer nioBuffer,
                                      int nPixelSpace,
                                      int nLineSpace)
        Write a region of image data for this band.

        This method allows writing data from a buffer into a region of the Band. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).

        The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.

        Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.

        For highest performance full resolution data access, write on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the WriteBlock(int, int, java.nio.ByteBuffer) method.

        Before writing into a multi-byte datatype buffer (GDT_Int16, GDT_Int32, GDT_Float32, ...), you should generally set the byte order of the buffer to the native order of the machine with nioBuffer.order(ByteOrder.nativeOrder()) (the default is BIG_ENDIAN) if you use the putShort(), putInt(), putFloat(), ... methods of the ByteBuffer class.

        Parameters:
        xoff - The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
        yoff - The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
        xsize - The width of the region of the band to be accessed in pixels.
        ysize - The height of the region of the band to be accessed in lines.
        buf_xsize - the width of the buffer image from which the desired region is to be written.
        buf_ysize - the height of the buffer image from which the desired region is to be written.
        buf_type - the type of the pixel values in the nioBuffer data buffer. One of gdalconstConstants.GDT_Byte, gdalconstConstants.GDT_Int16, ... The pixel values will automatically be translated to/from the GDALRasterBand data type as needed.
        nioBuffer - The buffer into which the data should be read. This buffer must contain at least buf_xsize * buf_ysize words of type buf_type. It is organized in left to right, top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters.
        nPixelSpace - The byte offset from the start of one pixel value in the buffer to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype buf_type is used.
        nLineSpace - The byte offset from the start of one scanline in the buffer to the start of the next. If defaulted the size of the datatype buf_type * buf_xsize is used.
        Returns:
        CE_Failure if the access fails, otherwise CE_None.
        Since:
        Java bindings 1.7.0
      • WriteRaster

        public int WriteRaster​(int xoff,
                               int yoff,
                               int xsize,
                               int ysize,
                               int buf_xsize,
                               int buf_ysize,
                               int buf_type,
                               byte[] array,
                               int nPixelSpace,
                               int nLineSpace)
        Write a region of image data for this band.

        This method allows writing data from a buffer into a region of the Band. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).

        The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.

        Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.

        For highest performance full resolution data access, write on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the WriteBlock(int, int, java.nio.ByteBuffer) method.

        Parameters:
        xoff - The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side.
        yoff - The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top.
        xsize - The width of the region of the band to be accessed in pixels.
        ysize - The height of the region of the band to be accessed in lines.
        buf_xsize - the width of the buffer image from which the desired region is to be written.
        buf_ysize - the height of the buffer image from which the desired region is to be written.
        buf_type - the type of the pixel values in the array. One of gdalconstConstants.GDT_Byte, gdalconstConstants.GDT_Int16, ... The pixel values will automatically be translated to/from the Band data type as needed. The GDAL type must be consistent with the type of the Java array.
        array - The buffer into which the data should be read. This buffer must contain at least buf_xsize * buf_ysize words of type buf_type. It is organized in left to right, top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters.
        nPixelSpace - The byte offset from the start of one pixel value in the buffer to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype buf_type is used.
        nLineSpace - The byte offset from the start of one scanline in the buffer to the start of the next. If defaulted the size of the datatype buf_type * buf_xsize is used.
        Returns:
        CE_Failure if the access fails, otherwise CE_None.
        Since:
        Java bindings 1.7.0
      • WriteRaster

        public int WriteRaster​(int xoff,
                               int yoff,
                               int xsize,
                               int ysize,
                               int buf_xsize,
                               int buf_ysize,
                               int buf_type,
                               long[] regularArrayIn,
                               int nPixelSpace,
                               int nLineSpace)
      • WriteRaster

        public int WriteRaster​(int xoff,
                               int yoff,
                               int xsize,
                               int ysize,
                               int buf_xsize,
                               int buf_ysize,
                               int buf_type,
                               long[] regularArrayIn,
                               int nPixelSpace)
      • WriteRaster

        public int WriteRaster​(int xoff,
                               int yoff,
                               int xsize,
                               int ysize,
                               int buf_xsize,
                               int buf_ysize,
                               int buf_type,
                               long[] regularArrayIn)
      • ReadBlock_Direct

        public int ReadBlock_Direct​(int nXBlockOff,
                                    int nYBlockOff,
                                    java.nio.ByteBuffer nioBuffer)
        Read a block of image data efficiently.

        This method accesses a "natural" block from the raster band without resampling, or data type conversion. For a more generalized, but potentially less efficient access use ReadRaster().

        Parameters:
        nXBlockOff - the horizontal block offset, with zero indicating the left most block, 1 the next block and so forth.
        nYBlockOff - the vertical block offset, with zero indicating the left most block, 1 the next block and so forth.
        nioBuffer - the buffer into which the data will be read. The buffer must be large enough to hold GetBlockXSize()*GetBlockYSize() words of type GetRasterDataType().
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure on an error.
        Since:
        Java bindings 1.7.0
      • WriteBlock_Direct

        public int WriteBlock_Direct​(int nXBlockOff,
                                     int nYBlockOff,
                                     java.nio.ByteBuffer nioBuffer)
        Write a block of image data efficiently.

        This method accesses a "natural" block from the raster band without resampling, or data type conversion. For a more generalized, but potentially less efficient access use WriteRaster().

        Parameters:
        nXBlockOff - the horizontal block offset, with zero indicating the left most block, 1 the next block and so forth.
        nYBlockOff - the vertical block offset, with zero indicating the left most block, 1 the next block and so forth.
        nioBuffer - the buffer from which the data will be written. The buffer must be large enough to hold GetBlockXSize()*GetBlockYSize() words of type GetRasterDataType().
        Returns:
        gdalconst.CE_None on success or gdalconst.CE_Failure on an error.
        Since:
        Java bindings 1.7.0
      • GetHistogram

        public int GetHistogram​(double min,
                                double max,
                                int[] histogram,
                                boolean include_out_of_range,
                                boolean approx_ok,
                                ProgressCallback callback)
        Compute raster histogram.

        Note that the bucket size is (dfMax-dfMin) / nBuckets.

        For example to compute a simple 256 entry histogram of eight bit data, the following would be suitable. The unusual bounds are to ensure that bucket boundaries don't fall right on integer values causing possible errors due to rounding after scaling.

             int anHistogram = new int[256];
        
             band.GetHistogram( -0.5, 255.5, 256, anHistogram, false, false, null);
         

        Note that setting approx_ok will generally result in a subsampling of the file, and will utilize overviews if available. It should generally produce a representative histogram for the data that is suitable for use in generating histogram based luts for instance. Generally bApproxOK is much faster than an exactly computed histogram.

        Parameters:
        min - the lower bound of the histogram.
        max - the upper bound of the histogram.
        histogram - allocated array into which the histogram totals are placed.
        include_out_of_range - if true values below the histogram range will mapped into anHistogram[0], and values above will be mapped into anHistogram[anHistogram.length-1] otherwise out of range values are discarded.
        approx_ok - true if an approximate, or incomplete histogram OK.
        callback - for reporting algorithm progress. May be null
        Returns:
        gdalconst.CE_None on success, or gdalconst.CE_Failure if something goes wrong.
        Since:
        Java bindings 1.7.0
      • GetDefaultHistogram

        public int GetDefaultHistogram​(double[] min_ret,
                                       double[] max_ret,
                                       int[][] histogram_ret,
                                       boolean force,
                                       ProgressCallback callback)
        Fetch default raster histogram.

        The default method in GDALRasterBand will compute a default histogram. This method is overridden by derived classes (such as GDALPamRasterBand, VRTDataset, HFADataset...) that may be able to fetch efficiently an already stored histogram.

        For example,

          double[] dfMin = new double[1];
          double[] dfMax = new double[1];
          int[][] panHistogram = new int[1][];
          int eErr = hBand.GetDefaultHistogram(dfMin, dfMax, panHistogram, true, new TermProgressCallback());
          if( eErr == gdalconst.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" );
          }
         
        Parameters:
        min_ret - allocated array of one double that will contain the lower bound of the histogram.
        max_ret - allocated array of one double that will contain the upper bound of the histogram.
        histogram_ret - allocated array of one int[] into which the histogram totals are placed.
        force - true to force the computation. If false and no default histogram is available, the method will return CE_Warning
        callback - for reporting algorithm progress. May be null
        Returns:
        gdalconst.CE_None on success, gdalconst.CE_Failure if something goes wrong, or gdalconst.CE_Warning if no default histogram is available.
        Since:
        Java bindings 1.7.0