Package org.geotools.process.raster
Class CoverageUtilities
- Object
-
- CoverageUtilities
-
public class CoverageUtilities extends Object
A set of utilities methods for the Grid Coverage package. Those methods are not really rigorous; must of them should be seen as temporary implementations.- Author:
- Simone Giannecchini, GeoSolutions
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Number
convert(Number val, Class<? extends Number> type)
static SimpleFeatureType
createFeatureType(GridCoverage2D gc2d, Class<? extends Geometry> geometryClass)
Creates aSimpleFeatureType
that exposes a coverage as a collections of feature points, mapping the centre of each pixel as a point plus all the bands as attributes.static GridCoverage2D
crop(GridCoverage2D coverage, ReferencedEnvelope geometryEnvelope)
Crops a given grid coverage to the specified geometry envelope using a coverage crop operation.static List<Range<Double>>
getNoDataAsList(GridCoverage2D coverage)
Retrieves the no data ranges for a given grid coverage.static RangeLookupTable
getRangeLookupTable(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue)
static RangeLookupTable
getRangeLookupTable(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, Class<? extends Number> clazz)
static RangeLookupTable
getRangeLookupTable(List<Range> classificationRanges, Number noDataValue)
static RangeLookupTable
getRangeLookupTable(List<Range> classificationRanges, Number noDataValue, Class clazz)
static RangeLookupTable
getRangeLookupTableJAIEXT(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, int transferType)
static HashMap<String,Double>
getRegionParamsFromGridCoverage(GridCoverage2D gridCoverage)
Get the parameters of the region covered by thecoverage
.static ROI
getSimplifiedRoiGeometry(GridCoverage2D coverage, Geometry geometry)
Converts a given geometry to a simplified Region of Interest (ROI) in raster space for a given grid coverage.static ROI
prepareROI(Geometry roi, AffineTransform mt2d)
Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation.
-
-
-
Field Detail
-
NORTH
public static final String NORTH
- See Also:
- Constant Field Values
-
SOUTH
public static final String SOUTH
- See Also:
- Constant Field Values
-
WEST
public static final String WEST
- See Also:
- Constant Field Values
-
EAST
public static final String EAST
- See Also:
- Constant Field Values
-
XRES
public static final String XRES
- See Also:
- Constant Field Values
-
YRES
public static final String YRES
- See Also:
- Constant Field Values
-
ROWS
public static final String ROWS
- See Also:
- Constant Field Values
-
COLS
public static final String COLS
- See Also:
- Constant Field Values
-
MINY
public static final String MINY
- See Also:
- Constant Field Values
-
MINX
public static final String MINX
- See Also:
- Constant Field Values
-
-
Method Detail
-
prepareROI
public static ROI prepareROI(Geometry roi, AffineTransform mt2d) throws ProcessException
Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation.- Parameters:
roi
- aGeometry
in model space.mt2d
- anAffineTransform
that maps from raster to model space. This is already referred to the pixel corner.- Returns:
- a
ROI
suitable for using with JAI. - Throws:
ProcessException
- in case there are problems with ivnerting the providedAffineTransform
. Very unlikely to happen.
-
createFeatureType
public static SimpleFeatureType createFeatureType(GridCoverage2D gc2d, Class<? extends Geometry> geometryClass)
Creates aSimpleFeatureType
that exposes a coverage as a collections of feature points, mapping the centre of each pixel as a point plus all the bands as attributes.The FID is the long that combines x+y*width.
- Parameters:
gc2d
- theGridCoverage2D
to wrap.geometryClass
- the class for the geometry.- Returns:
- a
SimpleFeatureType
ornull
in case we are unable to wrap the coverage
-
getRangeLookupTable
public static RangeLookupTable getRangeLookupTable(List<Range> classificationRanges, Number noDataValue)
-
getRangeLookupTable
public static RangeLookupTable getRangeLookupTable(List<Range> classificationRanges, Number noDataValue, Class clazz)
-
getRangeLookupTable
public static RangeLookupTable getRangeLookupTable(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue)
-
getRangeLookupTable
public static RangeLookupTable getRangeLookupTable(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, Class<? extends Number> clazz)
-
getRangeLookupTableJAIEXT
public static RangeLookupTable getRangeLookupTableJAIEXT(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, int transferType)
-
getRegionParamsFromGridCoverage
public static HashMap<String,Double> getRegionParamsFromGridCoverage(GridCoverage2D gridCoverage)
Get the parameters of the region covered by thecoverage
.
-
getNoDataAsList
public static List<Range<Double>> getNoDataAsList(GridCoverage2D coverage)
Retrieves the no data ranges for a given grid coverage.- Parameters:
coverage
- the grid coverage to extract nodata ranges from- Returns:
- a list of no data ranges, or null if no nodata ranges are found
-
crop
public static GridCoverage2D crop(GridCoverage2D coverage, ReferencedEnvelope geometryEnvelope)
Crops a given grid coverage to the specified geometry envelope using a coverage crop operation.- Parameters:
coverage
- The source grid coverage to be croppedgeometryEnvelope
- The envelope defining the crop region- Returns:
- A new GridCoverage2D cropped to the specified envelope
-
getSimplifiedRoiGeometry
public static ROI getSimplifiedRoiGeometry(GridCoverage2D coverage, Geometry geometry) throws TransformException
Converts a given geometry to a simplified Region of Interest (ROI) in raster space for a given grid coverage.- Parameters:
coverage
- The grid coverage defining the raster transformation contextgeometry
- The original geometry to be transformed and simplified- Returns:
- A simplified ROI geometry suitable for raster processing
- Throws:
TransformException
- If the geometry transformation fails
-
-