Package org.geotools.coverage.util
Class CoverageUtilities
Object
CoverageUtilities
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.
- Since:
- 2.4
- Author:
- Martin Desruisseaux (IRD), Simone Giannecchini, GeoSolutions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUnified Code for Units of Measure (UCUM) -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final AffineTransformAxes transposition for swapping Lat and Lon axes.static final AffineTransformAffineTransformthat can be used to go from an image datum placed at the center of pixels to one that is placed at ULC.static final AffineTransformAffineTransformthat can be used to go from an image datum placed at the ULC corner of pixels to one that is placed at center.static final AffineTransformIdentity affine transformation.static final InternationalStringPublic name for standard No Data category. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckEmptySourceRegion(ImageReadParam readParameters, Rectangle dimensions) Checks that the provideddimensionswhen intersected with the source region used by the providedImageReadParaminstance does not result in an emptyRectangle.static double[]getBackgroundValues(GridCoverage2D coverage) Retrieves a best guess for the sample value to use for background, inspecting the categories of the providedGridCoverage2D.static CoordinateReferenceSystemReturns a two-dimensional CRS for the given coverage.static ReferencedEnvelopegetEnvelope2D(Coverage coverage) Returns a two-dimensional envelope for the given coverage.static CoordinateReferenceSystemgetHorizontalCRS(Coverage coverage) Returns a two-dimensional horizontal CRS for the given coverage.static doublegetMosaicThreshold(int dataType) Returns a suitable threshold depending on theDataBuffertype.static NoDataContainergetNoDataProperty(GridCoverage2D coverage) Utility method for extracting NoData property from inputGridCoverage2D.static double[]getResolution(AffineTransform gridToCRS) Computes the resolutions for the provided "grid to world" transformation The returned resolution array is of length of 2.static ROIgetROIProperty(GridCoverage2D coverage) Utility method for extracting ROI property from inputGridCoverage2D.static intgetVisibleBand(Object image) Returns the visible band in the specifiedRenderedImageorPropertySource.static booleanisScaleTranslate(MathTransform transform, double EPS) Checks if the transformation is a pure scale/translate instance (using the provided tolerance factor)static booleanisSimpleGridToWorldTransform(AffineTransform gridToCRS, double EPS) Tries to estimate if the supplied affine transform is either a scale and translate transform or if it contains a rotations which is an integer multiple of PI/2.static PropertiesloadPropertiesFromURL(URL propsURL) Extract Properties from a specified URLstatic voidsetNoDataProperty(Map<String, Object> properties, Object noData) Utility method for setting NoData to the inputMapstatic voidsetROIProperty(Map<String, Object> properties, ROI roi) Utility method for setting ROI to the inputMapstatic NumbersuggestNoDataValue(int dataType) Returns a suitable no data value depending on theDataBuffertype.static booleanuses(GridCoverage coverage, RenderedImage image) Returnstrueif the specified grid coverage or any of its source uses the following image.
-
Field Details
-
NODATA
Public name for standard No Data category. -
AXES_SWAP
Axes transposition for swapping Lat and Lon axes. -
IDENTITY_TRANSFORM
Identity affine transformation. -
CENTER_TO_CORNER
AffineTransformthat can be used to go from an image datum placed at the center of pixels to one that is placed at ULC. -
CORNER_TO_CENTER
AffineTransformthat can be used to go from an image datum placed at the ULC corner of pixels to one that is placed at center. -
AFFINE_IDENTITY_EPS
public static final double AFFINE_IDENTITY_EPS- See Also:
-
-
Method Details
-
getCRS2D
Returns a two-dimensional CRS for the given coverage. This method performs a best effort; the returned CRS is not garanteed to be the most appropriate one.- Parameters:
coverage- The coverage for which to obtains a two-dimensional CRS.- Returns:
- The two-dimensional CRS.
- Throws:
TransformException- if the CRS can't be reduced to two dimensions.
-
getHorizontalCRS
public static CoordinateReferenceSystem getHorizontalCRS(Coverage coverage) throws TransformException Returns a two-dimensional horizontal CRS for the given coverage. This method performs a best effort; the returned CRS is not garanteed to succed.- Parameters:
coverage- The coverage for which to obtains a two-dimensional horizontal CRS.- Returns:
- The two-dimensional horizontal CRS.
- Throws:
TransformException- if the CRS can't be reduced to two dimensions.
-
getEnvelope2D
public static ReferencedEnvelope getEnvelope2D(Coverage coverage) throws MismatchedDimensionException Returns a two-dimensional envelope for the given coverage. This method performs a best effort; the returned envelope is not garanteed to be the most appropriate one.- Parameters:
coverage- The coverage for which to obtains a two-dimensional envelope.- Returns:
- The two-dimensional envelope.
- Throws:
MismatchedDimensionException- if the envelope can't be reduced to two dimensions.
-
getNoDataProperty
Utility method for extracting NoData property from inputGridCoverage2D.- Returns:
- A
NoDataContainerobject containing input NoData definition
-
getROIProperty
Utility method for extracting ROI property from inputGridCoverage2D.- Returns:
- A
ROIobject
-
setNoDataProperty
Utility method for setting NoData to the inputMap- Parameters:
properties-Mapwhere the nodata will be setnoData- May be aRange,double[],doubleorNoDataContainer
-
setROIProperty
Utility method for setting ROI to the inputMap- Parameters:
properties-Mapwhere the ROI will be setroi-ROIinstance to set
-
getBackgroundValues
Retrieves a best guess for the sample value to use for background, inspecting the categories of the providedGridCoverage2D.- Parameters:
coverage- to use for guessing background values.- Returns:
- an array of double values to use as a background.
-
uses
Returnstrueif the specified grid coverage or any of its source uses the following image. -
getVisibleBand
Returns the visible band in the specifiedRenderedImageorPropertySource. This method fetch the"GC_VisibleBand"property. If this property is undefined, then the visible band default to the first one.- Parameters:
image- The image for which to fetch the visible band, ornull.- Returns:
- The visible band.
-
isScaleTranslate
Checks if the transformation is a pure scale/translate instance (using the provided tolerance factor)- Parameters:
transform- TheMathTransformto check.EPS- The tolerance factor.- Returns:
trueif the provided transformation is a simple scale and translate,falseotherwise.
-
getResolution
Computes the resolutions for the provided "grid to world" transformation The returned resolution array is of length of 2.- Parameters:
gridToCRS- The grid to world transformation.
-
isSimpleGridToWorldTransform
Tries to estimate if the supplied affine transform is either a scale and translate transform or if it contains a rotations which is an integer multiple of PI/2.- Parameters:
gridToCRS- an instance ofAffineTransformto check against.EPS- tolerance value for comparisons.- Returns:
trueif this transform is "simple",falseotherwise.
-
checkEmptySourceRegion
Checks that the provideddimensionswhen intersected with the source region used by the providedImageReadParaminstance does not result in an emptyRectangle. Finally, in case the region intersection is not empty, set it as new source region for the providedImageReadParam.Input parameters cannot be null.
- Parameters:
readParameters- an instance ofImageReadParamfor which we want to check the source region element.dimensions- an instance ofRectangleto use for the check.- Returns:
trueif the intersection is not empty,falseotherwise.
-
getMosaicThreshold
public static double getMosaicThreshold(int dataType) Returns a suitable threshold depending on theDataBuffertype.Remember that the threshold works with >=.
- Parameters:
dataType- to create a low threshold for.- Returns:
- a minimum threshold value suitable for this data type.
-
suggestNoDataValue
Returns a suitable no data value depending on theDataBuffertype.- Parameters:
dataType- to create a low threshold for.- Returns:
- a no data value suitable for this data type.
-
loadPropertiesFromURL
Extract Properties from a specified URL
-