Class RasterConstructors

java.lang.Object
org.apache.sedona.common.raster.RasterConstructors

public class RasterConstructors extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.geotools.coverage.grid.GridCoverage2D
    asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType)
    Returns a raster that is converted from the geometry provided.
    static org.geotools.coverage.grid.GridCoverage2D
    asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched)
    Returns a raster that is converted from the geometry provided.
    static org.geotools.coverage.grid.GridCoverage2D
    asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value)
    Returns a raster that is converted from the geometry provided.
    static org.geotools.coverage.grid.GridCoverage2D
    asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value, Double noDataValue)
    Returns a raster that is converted from the geometry provided.
    static org.geotools.coverage.grid.GridCoverage2D
    asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value, Double noDataValue, boolean useGeometryExtent)
    Returns a raster that is converted from the geometry provided.
    static org.geotools.coverage.grid.GridCoverage2D
    asRasterWithRasterExtent(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value, Double noDataValue)
    For internal use only! Returns a raster that is converted from the geometry provided with the extent of the reference raster.
    static org.geotools.coverage.grid.GridCoverage2D
    fromArcInfoAsciiGrid(byte[] bytes)
     
    static org.geotools.coverage.grid.GridCoverage2D
    fromGeoTiff(byte[] bytes)
     
    static org.geotools.coverage.grid.GridCoverage2D
    fromNetCDF(byte[] bytes, String recordVariableName)
     
    static org.geotools.coverage.grid.GridCoverage2D
    fromNetCDF(byte[] bytes, String variableName, String lonDimensionName, String latDimensionName)
     
    generateTiles(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight, boolean padWithNoData, double padNoDataValue)
    Generate tiles from a grid coverage
    static org.geotools.feature.DefaultFeatureCollection
    getFeatureCollection(org.locationtech.jts.geom.Geometry geom, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs)
     
    static String
    getRecordInfo(byte[] bytes)
     
    static org.geotools.coverage.grid.GridCoverage2D
    makeEmptyRaster(int numBand, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double pixelSize)
    Convenience function setting DOUBLE as datatype for the bands Create a new empty raster with the given number of empty bands.
    static org.geotools.coverage.grid.GridCoverage2D
    makeEmptyRaster(int numBand, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid)
    Convenience function for creating a raster with data type DOUBLE for all the bands
    static org.geotools.coverage.grid.GridCoverage2D
    makeEmptyRaster(int numBand, String dataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double pixelSize)
    Convenience function allowing explicitly setting the datatype for all the bands
    static org.geotools.coverage.grid.GridCoverage2D
    makeEmptyRaster(int numBand, String bandDataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid)
    Create a new empty raster with the given number of empty bands
    static org.geotools.coverage.grid.GridCoverage2D
    makeNonEmptyRaster(int numBand, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid, double[][] data, Map<String,List<String>> properties, Double noDataValue, org.geotools.api.referencing.datum.PixelInCell anchor)
     
    static org.geotools.coverage.grid.GridCoverage2D
    makeNonEmptyRaster(int numBands, String bandDataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid, double[][] rasterValues)
     
    static org.geotools.coverage.grid.GridCoverage2D
    makeNonEmptyRaster(org.geotools.coverage.grid.GridCoverage2D ref, String bandDataType, double[] values)
    Make a non-empty raster from a reference raster and a set of values.
    static org.geotools.coverage.grid.GridCoverage2D[]
    rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight)
     
    static org.geotools.coverage.grid.GridCoverage2D[]
    rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight, boolean padWithNoData)
     
    static org.geotools.coverage.grid.GridCoverage2D[]
    rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight, boolean padWithNoData, Double padNoDataValue)
     
    static org.geotools.coverage.grid.GridCoverage2D[]
    rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int tileWidth, int tileHeight)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RasterConstructors

      public RasterConstructors()
  • Method Details

    • fromArcInfoAsciiGrid

      public static org.geotools.coverage.grid.GridCoverage2D fromArcInfoAsciiGrid(byte[] bytes) throws IOException
      Throws:
      IOException
    • fromGeoTiff

      public static org.geotools.coverage.grid.GridCoverage2D fromGeoTiff(byte[] bytes) throws IOException
      Throws:
      IOException
    • fromNetCDF

      public static org.geotools.coverage.grid.GridCoverage2D fromNetCDF(byte[] bytes, String variableName, String lonDimensionName, String latDimensionName) throws IOException, org.geotools.api.referencing.FactoryException
      Throws:
      IOException
      org.geotools.api.referencing.FactoryException
    • fromNetCDF

      public static org.geotools.coverage.grid.GridCoverage2D fromNetCDF(byte[] bytes, String recordVariableName) throws IOException, org.geotools.api.referencing.FactoryException
      Throws:
      IOException
      org.geotools.api.referencing.FactoryException
    • getRecordInfo

      public static String getRecordInfo(byte[] bytes) throws IOException
      Throws:
      IOException
    • asRaster

      public static org.geotools.coverage.grid.GridCoverage2D asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value, Double noDataValue, boolean useGeometryExtent) throws org.geotools.api.referencing.FactoryException
      Returns a raster that is converted from the geometry provided.
      Parameters:
      geom - The geometry to convert
      raster - The reference raster
      pixelType - The data type of pixel/cell of resultant raster
      allTouched - When set to true, rasterizes all pixels touched by geom
      value - The value of the pixel of the resultant raster
      noDataValue - The noDataValue of the resultant raster
      useGeometryExtent - The way to generate extent of the resultant raster. Use the extent of the geometry to convert if true, else use the extent of the reference raster
      Returns:
      Rasterized Geometry
      Throws:
      org.geotools.api.referencing.FactoryException
    • asRaster

      public static org.geotools.coverage.grid.GridCoverage2D asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value, Double noDataValue) throws org.geotools.api.referencing.FactoryException
      Returns a raster that is converted from the geometry provided. A convenience function for asRaster.
      Parameters:
      geom - The geometry to convert
      raster - The reference raster
      pixelType - The data type of pixel/cell of resultant raster
      allTouched - When set to true, rasterizes all pixels touched by geom
      value - The value of the pixel of the resultant raster
      noDataValue - The noDataValue of the resultant raster
      Returns:
      Rasterized Geometry
      Throws:
      org.geotools.api.referencing.FactoryException
    • asRaster

      public static org.geotools.coverage.grid.GridCoverage2D asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType) throws org.geotools.api.referencing.FactoryException
      Returns a raster that is converted from the geometry provided. A convenience function for asRaster.
      Parameters:
      geom - The geometry to convert
      raster - The reference raster
      pixelType - The data type of pixel/cell of resultant raster.
      Returns:
      Rasterized Geometry
      Throws:
      org.geotools.api.referencing.FactoryException
    • asRaster

      public static org.geotools.coverage.grid.GridCoverage2D asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched) throws org.geotools.api.referencing.FactoryException
      Returns a raster that is converted from the geometry provided. A convenience function for asRaster.
      Parameters:
      geom - The geometry to convert
      raster - The reference raster
      pixelType - The data type of pixel/cell of resultant raster.
      allTouched - When set to true, rasterizes all pixels touched by geom
      Returns:
      Rasterized Geometry
      Throws:
      org.geotools.api.referencing.FactoryException
    • asRaster

      public static org.geotools.coverage.grid.GridCoverage2D asRaster(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value) throws org.geotools.api.referencing.FactoryException
      Returns a raster that is converted from the geometry provided. A convenience function for asRaster.
      Parameters:
      geom - The geometry to convert
      raster - The reference raster
      pixelType - The data type of pixel/cell of resultant raster.
      allTouched - When set to true, rasterizes all pixels touched by geom
      value - The value of the pixel of the resultant raster
      Returns:
      Rasterized Geometry
      Throws:
      org.geotools.api.referencing.FactoryException
    • asRasterWithRasterExtent

      public static org.geotools.coverage.grid.GridCoverage2D asRasterWithRasterExtent(org.locationtech.jts.geom.Geometry geom, org.geotools.coverage.grid.GridCoverage2D raster, String pixelType, boolean allTouched, double value, Double noDataValue) throws org.geotools.api.referencing.FactoryException
      For internal use only! Returns a raster that is converted from the geometry provided with the extent of the reference raster.
      Parameters:
      geom - The geometry to convert
      raster - The reference raster
      pixelType - The data type of pixel/cell of resultant raster
      value - The value of the pixel of the resultant raster
      noDataValue - The noDataValue of the resultant raster
      Returns:
      Rasterized Geometry with reference raster's extent
      Throws:
      org.geotools.api.referencing.FactoryException
    • getFeatureCollection

      public static org.geotools.feature.DefaultFeatureCollection getFeatureCollection(org.locationtech.jts.geom.Geometry geom, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs)
    • makeEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeEmptyRaster(int numBand, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double pixelSize) throws org.geotools.api.referencing.FactoryException
      Convenience function setting DOUBLE as datatype for the bands Create a new empty raster with the given number of empty bands. The bounding envelope is defined by the upper left corner and the scale. The math formula of the envelope is: minX = upperLeftX = lowerLeftX, minY (lowerLeftY) = upperLeftY - height * pixelSize
      • The raster is defined by the width and height
      • The upper left corner is defined by the upperLeftX and upperLeftY
      • The scale is defined by pixelSize. The scaleX is equal to pixelSize and scaleY is equal to -pixelSize
      • skewX and skewY are zero, which means no shear or rotation.
      • SRID is default to 0 which means the default CRS (Generic 2D)
      Parameters:
      numBand - the number of bands
      widthInPixel - the width of the raster, in pixel
      heightInPixel - the height of the raster, in pixel
      upperLeftX - the upper left corner of the raster. Note that: the minX of the envelope is equal to the upperLeftX
      upperLeftY - the upper left corner of the raster. Note that: the minY of the envelope is equal to the upperLeftY - height * pixelSize
      pixelSize - the size of the pixel in the unit of the CRS
      Returns:
      the new empty raster
      Throws:
      org.geotools.api.referencing.FactoryException
    • makeEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeEmptyRaster(int numBand, String dataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double pixelSize) throws org.geotools.api.referencing.FactoryException
      Convenience function allowing explicitly setting the datatype for all the bands
      Parameters:
      numBand -
      dataType -
      widthInPixel -
      heightInPixel -
      upperLeftX -
      upperLeftY -
      pixelSize -
      Returns:
      Throws:
      org.geotools.api.referencing.FactoryException
    • makeEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeEmptyRaster(int numBand, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid) throws org.geotools.api.referencing.FactoryException
      Convenience function for creating a raster with data type DOUBLE for all the bands
      Parameters:
      numBand -
      widthInPixel -
      heightInPixel -
      upperLeftX -
      upperLeftY -
      scaleX -
      scaleY -
      skewX -
      skewY -
      srid -
      Returns:
      Throws:
      org.geotools.api.referencing.FactoryException
    • makeEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeEmptyRaster(int numBand, String bandDataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid) throws org.geotools.api.referencing.FactoryException
      Create a new empty raster with the given number of empty bands
      Parameters:
      numBand - the number of bands
      bandDataType - the data type of the raster, one of D | B | I | F | S | US
      widthInPixel - the width of the raster, in pixel
      heightInPixel - the height of the raster, in pixel
      upperLeftX - the upper left corner of the raster, in the CRS unit. Note that: the minX of the envelope is equal to the upperLeftX
      upperLeftY - the upper left corner of the raster, in the CRS unit. Note that: the minY of the envelope is equal to the upperLeftY + height * scaleY
      scaleX - the scale of the raster (pixel size on X), in the CRS unit
      scaleY - the scale of the raster (pixel size on Y), in the CRS unit
      skewX - the skew of the raster on X, in the CRS unit
      skewY - the skew of the raster on Y, in the CRS unit
      srid - the srid of the CRS. 0 means the default CRS (Cartesian 2D)
      Returns:
      the new empty raster
      Throws:
      org.geotools.api.referencing.FactoryException
    • makeNonEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeNonEmptyRaster(int numBand, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid, double[][] data, Map<String,List<String>> properties, Double noDataValue, org.geotools.api.referencing.datum.PixelInCell anchor) throws org.geotools.api.referencing.FactoryException
      Throws:
      org.geotools.api.referencing.FactoryException
    • makeNonEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeNonEmptyRaster(int numBands, String bandDataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double scaleX, double scaleY, double skewX, double skewY, int srid, double[][] rasterValues)
    • makeNonEmptyRaster

      public static org.geotools.coverage.grid.GridCoverage2D makeNonEmptyRaster(org.geotools.coverage.grid.GridCoverage2D ref, String bandDataType, double[] values)
      Make a non-empty raster from a reference raster and a set of values. The constructed raster will have the same CRS, geo-reference metadata, width and height as the reference raster. The number of bands of the reference raster is determined by the size of values. The size of values should be multiple of width * height of the reference raster.
      Parameters:
      ref - the reference raster
      bandDataType - the data type of the band
      values - the values to set
      Returns:
      the constructed raster
    • generateTiles

      public static RasterConstructors.Tile[] generateTiles(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight, boolean padWithNoData, double padNoDataValue)
      Generate tiles from a grid coverage
      Parameters:
      gridCoverage2D - the grid coverage
      bandIndices - the indices of the bands to select (1-based), can be null or empty to include all the bands.
      tileWidth - the width of the tiles
      tileHeight - the height of the tiles
      padWithNoData - whether to pad the tiles with no data value
      padNoDataValue - the no data value for padded tiles, only used when padWithNoData is true. If the value is NaN, the no data value of the original band will be used.
      Returns:
      the tiles
    • rsTile

      public static org.geotools.coverage.grid.GridCoverage2D[] rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight, boolean padWithNoData, Double padNoDataValue)
    • rsTile

      public static org.geotools.coverage.grid.GridCoverage2D[] rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight, boolean padWithNoData)
    • rsTile

      public static org.geotools.coverage.grid.GridCoverage2D[] rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int[] bandIndices, int tileWidth, int tileHeight)
    • rsTile

      public static org.geotools.coverage.grid.GridCoverage2D[] rsTile(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, int tileWidth, int tileHeight)