Package org.geotools.process.raster
Class CoverageUtilities
Object
CoverageUtilities
A set of utilities methods for the Grid Coverage package. Those methods are not really rigorous; many of them should
be seen as temporary implementations.
- Author:
- Simone Giannecchini, GeoSolutions
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Number
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 <T extends Number>
RangecreateRange
(T minValue, boolean minIncluded, T maxValue, boolean maxIncluded) Static create method.static GridCoverage2D
crop
(GridCoverage2D coverage, ReferencedEnvelope geometryEnvelope) Crops a given grid coverage to the specified geometry envelope using a coverage crop operation.static List<RangeDouble>
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, int transferType) Setup lookup table from classification ranges.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) 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 Details
-
NORTH
- See Also:
-
SOUTH
- See Also:
-
WEST
- See Also:
-
EAST
- See Also:
-
XRES
- See Also:
-
YRES
- See Also:
-
ROWS
- See Also:
-
COLS
- See Also:
-
MINY
- See Also:
-
MINX
- See Also:
-
-
Method Details
-
prepareROI
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
-
createRange
public static <T extends Number> Range createRange(T minValue, boolean minIncluded, T maxValue, boolean maxIncluded) Static create method. This just relieves the tedium of having to call create RangeFactory create method.- Type Parameters:
T
- value type- Parameters:
minValue
- the lower bound; passing null for this parameter means an open lower bound; for Float or Double types, the relevant NEGATIVE_INFINITY value can also be used.minIncluded
- true if the lower bound is to be included in the range; false to exclude the lower bound; overridden to be false if the lower bound is openmaxValue
- the upper bound; passing null for this parameter means an open upper bound; for Float or Double types, the relevant NEGATIVE_INFINITY value can also be used.maxIncluded
- true if the upper bound is to be included in the range; false to exclude the upper bound; overridden to be false if the upper bound is open- Returns:
- the new instance
-
getRangeLookupTable
-
getRangeLookupTable
-
getRangeLookupTable
-
getRangeLookupTable
-
getRangeLookupTable
public static RangeLookupTable getRangeLookupTable(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, int transferType) Setup lookup table from classification ranges.- Parameters:
classificationRanges
-outputPixelValues
-noDataValue
-transferType
-- Returns:
- lookup table
-
convert
-
getRegionParamsFromGridCoverage
Get the parameters of the region covered by thecoverage
. -
getNoDataAsList
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
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
-