Class GdalDataset

java.lang.Object
com.eco.bio7.gdal.GdalDataset
All Implemented Interfaces:
AutoCloseable

public final class GdalDataset extends Object implements AutoCloseable
A dataset of GDAL: a raster (bands of pixels with georeferencing) and/or vector layers. Close it after use (try-with-resources).
  • Method Details

    • path

      public String path()
      The path (or name) the dataset was opened or created with.
    • width

      public int width()
    • height

      public int height()
    • bandCount

      public int bandCount()
    • band

      public GdalBand band(int index)
      The band (1 to bandCount()).
    • geoTransform

      public double[] geoTransform()
      The georeferencing (affine transformation): x = gt[0] + col * gt[1] + row * gt[2], y = gt[3] + col * gt[4] + row * gt[5]; null if the dataset has none.
    • setGeoTransform

      public void setGeoTransform(double[] gt)
    • projection

      public String projection()
      The coordinate system as WKT ("" if none).
    • setProjection

      public void setProjection(String crs)
      Sets the coordinate system (WKT, or "EPSG:4326", a PROJ string, ...).
    • spatialReference

      public SpatialReference spatialReference()
      The coordinate system (null if the dataset has none). Close it after use.
    • bounds

      public double[] bounds()
      The extent {minX, minY, maxX, maxY} in the coordinates of the dataset (null without georeferencing).
    • pixelToWorld

      public double[] pixelToWorld(double column, double row)
      The coordinates {x, y} of a pixel position (column, row; 0.5 is the center of the first pixel).
    • worldToPixel

      public double[] worldToPixel(double x, double y)
      The pixel position {column, row} of coordinates of the dataset.
    • driverName

      public String driverName()
      The short name of the driver (e.g., "GTiff").
    • metadata

      public Map<String,String> metadata(String domain)
      The metadata of a domain (null or "" for the default domain), e.g. the tags of a GeoTIFF.
    • files

      public List<String> files()
      The files of the dataset (e.g., a shapefile: .shp, .shx, .dbf, .prj).
    • info

      public String info(String... options)
      The output of gdalinfo for this dataset (options of gdalinfo, e.g. "-stats", "-json").
    • layerCount

      public int layerCount()
    • layer

      public VectorLayer layer(int index)
      The vector layer (0 to layerCount() - 1).
    • createLayer

      public VectorLayer createLayer(String name, SpatialReference srs, GeometryType type, String... options)
      A new vector layer (a dataset of a vector driver, see Gdal.createVector(String, String, String...)): its coordinate system (or null), the type of the geometries and the options of the driver (e.g., "GEOMETRY_NAME=geom").
    • executeSql

      public VectorLayer executeSql(String sql)
      Executes SQL (the dialect of the driver, e.g. of GeoPackage or SQLite). The result is a layer: close it after use.
    • executeSql

      public VectorLayer executeSql(String sql, String dialect)
      Executes SQL in a dialect ("OGRSQL", "SQLITE", "INDIRECT_SQLITE" or null for the dialect of the driver). The result is a layer (null for statements without result): close it after use.
    • layers

      public List<VectorLayer> layers()
    • flush

      public void flush()
      Writes the cached data (of a created or updated dataset).
    • isClosed

      public boolean isClosed()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object