Class GdalBand

java.lang.Object
com.eco.bio7.gdal.GdalBand

public final class GdalBand extends Object
A band of a raster dataset: its pixels as Java arrays (row by row, the first row is the top), the no data value, the color table and the statistics. GDAL converts the pixels to the type of the array.
  • Method Summary

    Modifier and Type
    Method
    Description
    The color interpretation (e.g., "Gray", "Red", "Palette", "Alpha").
    int[]
    The color table as ARGB values (index -> color), null if the band has none.
    void
    contours(VectorLayer target, double interval, String... options)
    Contour lines of the band into a vector layer (gdal_contour): the fields "ID" and "ELEV" are created if they don't exist; the no data value of the band is used.
     
    int
     
    int
     
    double[]
    minMax(boolean approximate)
    {min, max} of the values (without the no data value; approximate: faster for large rasters).
    The value of the pixels without data (null if not set).
    double
    The offset of the values (value = raw * scale + offset), 0 if not set.
    void
    polygonize(VectorLayer target, String field, boolean useMask, String... options)
    Polygons of the areas of equal values (gdal_polygonize) into a vector layer: the value of each polygon in the field (created if it doesn't exist: integer, or real for float bands).
    byte[]
    The pixels as 8 bit values (unsigned: invalid input: '&' 0xff).
    byte[]
    readBytes(int x, int y, int w, int h)
     
    double[]
     
    double[]
    readDoubles(int x, int y, int w, int h)
    The pixels of a window as double values (row by row).
    float[]
     
    float[]
    readFloats(int x, int y, int w, int h)
     
    float[]
    readFloats(int x, int y, int w, int h, int bufferWidth, int bufferHeight)
    The pixels of a window resampled to the size of the buffer (e.g., an overview of a large raster: GDAL uses the overviews of the file).
    int[]
     
    int[]
    readInts(int x, int y, int w, int h)
     
    short[]
    The pixels as 16 bit values (UInt16 or Int16 rasters; unsigned: invalid input: '&' 0xffff).
    short[]
    readShorts(int x, int y, int w, int h)
     
    double
    The scale of the values (value = raw * scale + offset), 1 if not set.
    void
    setNoData(double value)
     
     
    int
     
    void
    write(byte[] values)
    Writes 8 bit values (unsigned).
    void
    write(double[] values)
     
    void
    write(float[] values)
     
    void
    write(int[] values)
     
    void
    write(int x, int y, int w, int h, byte[] values)
     
    void
    write(int x, int y, int w, int h, double[] values)
     
    void
    write(int x, int y, int w, int h, float[] values)
     
    void
    write(int x, int y, int w, int h, int[] values)
     
    void
    write(int x, int y, int w, int h, short[] values)
     
    void
    write(short[] values)
    Writes 16 bit values (as UInt16, or Int16 for an Int16 band).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • index

      public int index()
    • width

      public int width()
    • height

      public int height()
    • dataType

      public GdalDataType dataType()
    • noData

      public Double noData()
      The value of the pixels without data (null if not set).
    • setNoData

      public void setNoData(double value)
    • colorInterpretation

      public String colorInterpretation()
      The color interpretation (e.g., "Gray", "Red", "Palette", "Alpha").
    • colorTable

      public int[] colorTable()
      The color table as ARGB values (index -> color), null if the band has none.
    • scale

      public double scale()
      The scale of the values (value = raw * scale + offset), 1 if not set.
    • offset

      public double offset()
      The offset of the values (value = raw * scale + offset), 0 if not set.
    • minMax

      public double[] minMax(boolean approximate)
      {min, max} of the values (without the no data value; approximate: faster for large rasters).
    • readDoubles

      public double[] readDoubles()
    • readDoubles

      public double[] readDoubles(int x, int y, int w, int h)
      The pixels of a window as double values (row by row).
    • readFloats

      public float[] readFloats()
    • readFloats

      public float[] readFloats(int x, int y, int w, int h)
    • readInts

      public int[] readInts()
    • readInts

      public int[] readInts(int x, int y, int w, int h)
    • readShorts

      public short[] readShorts()
      The pixels as 16 bit values (UInt16 or Int16 rasters; unsigned: invalid input: '&' 0xffff).
    • readShorts

      public short[] readShorts(int x, int y, int w, int h)
    • readBytes

      public byte[] readBytes()
      The pixels as 8 bit values (unsigned: invalid input: '&' 0xff).
    • readBytes

      public byte[] readBytes(int x, int y, int w, int h)
    • readFloats

      public float[] readFloats(int x, int y, int w, int h, int bufferWidth, int bufferHeight)
      The pixels of a window resampled to the size of the buffer (e.g., an overview of a large raster: GDAL uses the overviews of the file).
    • write

      public void write(double[] values)
    • write

      public void write(int x, int y, int w, int h, double[] values)
    • write

      public void write(float[] values)
    • write

      public void write(int x, int y, int w, int h, float[] values)
    • write

      public void write(int[] values)
    • write

      public void write(int x, int y, int w, int h, int[] values)
    • write

      public void write(short[] values)
      Writes 16 bit values (as UInt16, or Int16 for an Int16 band).
    • write

      public void write(int x, int y, int w, int h, short[] values)
    • write

      public void write(byte[] values)
      Writes 8 bit values (unsigned).
    • write

      public void write(int x, int y, int w, int h, byte[] values)
    • contours

      public void contours(VectorLayer target, double interval, String... options)
      Contour lines of the band into a vector layer (gdal_contour): the fields "ID" and "ELEV" are created if they don't exist; the no data value of the band is used. Further options of GDALContourGenerateEx, e.g. "LEVEL_BASE=100", "FIXED_LEVELS=500,1000", "POLYGONIZE=YES" (with "ELEV_FIELD_MIN=..." and "ELEV_FIELD_MAX=...").
    • polygonize

      public void polygonize(VectorLayer target, String field, boolean useMask, String... options)
      Polygons of the areas of equal values (gdal_polygonize) into a vector layer: the value of each polygon in the field (created if it doesn't exist: integer, or real for float bands). useMask: the pixels without data (the mask of the band) get no polygons. Options of GDALPolygonize, e.g. "8CONNECTED=8".
    • toString

      public String toString()
      Overrides:
      toString in class Object