Package org.apache.sedona.common.raster
Class RasterConstructors
java.lang.Object
org.apache.sedona.common.raster.RasterConstructors
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.geotools.coverage.grid.GridCoverage2DasRaster(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.GridCoverage2DasRaster(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.GridCoverage2DasRaster(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.GridCoverage2DasRaster(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.GridCoverage2DasRaster(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.GridCoverage2DasRasterWithRasterExtent(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.GridCoverage2DfromArcInfoAsciiGrid(byte[] bytes) static org.geotools.coverage.grid.GridCoverage2DfromGeoTiff(byte[] bytes) static org.geotools.coverage.grid.GridCoverage2DfromNetCDF(byte[] bytes, String recordVariableName) static org.geotools.coverage.grid.GridCoverage2DfromNetCDF(byte[] bytes, String variableName, String lonDimensionName, String latDimensionName) 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 coveragestatic org.geotools.feature.DefaultFeatureCollectiongetFeatureCollection(org.locationtech.jts.geom.Geometry geom, org.geotools.api.referencing.crs.CoordinateReferenceSystem crs) static StringgetRecordInfo(byte[] bytes) static org.geotools.coverage.grid.GridCoverage2DmakeEmptyRaster(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.GridCoverage2DmakeEmptyRaster(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 bandsstatic org.geotools.coverage.grid.GridCoverage2DmakeEmptyRaster(int numBand, String dataType, int widthInPixel, int heightInPixel, double upperLeftX, double upperLeftY, double pixelSize) Convenience function allowing explicitly setting the datatype for all the bandsstatic org.geotools.coverage.grid.GridCoverage2DmakeEmptyRaster(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 bandsstatic org.geotools.coverage.grid.GridCoverage2DmakeNonEmptyRaster(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.GridCoverage2DmakeNonEmptyRaster(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.GridCoverage2DmakeNonEmptyRaster(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)
-
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:
IOExceptionorg.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:
IOExceptionorg.geotools.api.referencing.FactoryException
-
getRecordInfo
- 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 convertraster- The reference rasterpixelType- The data type of pixel/cell of resultant rasterallTouched- When set to true, rasterizes all pixels touched by geomvalue- The value of the pixel of the resultant rasternoDataValue- The noDataValue of the resultant rasteruseGeometryExtent- 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 convertraster- The reference rasterpixelType- The data type of pixel/cell of resultant rasterallTouched- When set to true, rasterizes all pixels touched by geomvalue- The value of the pixel of the resultant rasternoDataValue- 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 convertraster- The reference rasterpixelType- 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 convertraster- The reference rasterpixelType- 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 convertraster- The reference rasterpixelType- The data type of pixel/cell of resultant raster.allTouched- When set to true, rasterizes all pixels touched by geomvalue- 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 convertraster- The reference rasterpixelType- The data type of pixel/cell of resultant rastervalue- The value of the pixel of the resultant rasternoDataValue- 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 bandswidthInPixel- the width of the raster, in pixelheightInPixel- the height of the raster, in pixelupperLeftX- the upper left corner of the raster. Note that: the minX of the envelope is equal to the upperLeftXupperLeftY- the upper left corner of the raster. Note that: the minY of the envelope is equal to the upperLeftY - height * pixelSizepixelSize- 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 bandsbandDataType- the data type of the raster, one of D | B | I | F | S | USwidthInPixel- the width of the raster, in pixelheightInPixel- the height of the raster, in pixelupperLeftX- the upper left corner of the raster, in the CRS unit. Note that: the minX of the envelope is equal to the upperLeftXupperLeftY- the upper left corner of the raster, in the CRS unit. Note that: the minY of the envelope is equal to the upperLeftY + height * scaleYscaleX- the scale of the raster (pixel size on X), in the CRS unitscaleY- the scale of the raster (pixel size on Y), in the CRS unitskewX- the skew of the raster on X, in the CRS unitskewY- the skew of the raster on Y, in the CRS unitsrid- 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 rasterbandDataType- the data type of the bandvalues- 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 coveragebandIndices- the indices of the bands to select (1-based), can be null or empty to include all the bands.tileWidth- the width of the tilestileHeight- the height of the tilespadWithNoData- whether to pad the tiles with no data valuepadNoDataValue- 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)
-