Package org.geotools.coverage.util
Class CoverageUtilities
- Object
-
- CoverageUtilities
-
public final 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.- Since:
- 2.4
- Author:
- Martin Desruisseaux (IRD), Simone Giannecchini, GeoSolutions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCoverageUtilities.UCUMUnified Code for Units of Measure (UCUM)
-
Field Summary
Fields Modifier and Type Field Description static doubleAFFINE_IDENTITY_EPSstatic AffineTransformAXES_SWAPAxes transposition for swapping Lat and Lon axes.static AffineTransformCENTER_TO_CORNERAffineTransformthat can be used to go from an image datum placed at the center of pixels to one that is placed at ULC.static AffineTransformCORNER_TO_CENTERAffineTransformthat can be used to go from an image datum placed at the ULC corner of pixels to one that is placed at center.static AffineTransformIDENTITY_TRANSFORMIdentity affine transformation.static InternationalStringNODATAPublic name for standard No Data category.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 CoordinateReferenceSystemgetCRS2D(Coverage coverage)Returns 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 Detail
-
NODATA
public static final InternationalString NODATA
Public name for standard No Data category.
-
AXES_SWAP
public static final AffineTransform AXES_SWAP
Axes transposition for swapping Lat and Lon axes.
-
IDENTITY_TRANSFORM
public static final AffineTransform IDENTITY_TRANSFORM
Identity affine transformation.
-
CENTER_TO_CORNER
public static final AffineTransform 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
public static final AffineTransform 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:
- Constant Field Values
-
-
Method Detail
-
getCRS2D
public static CoordinateReferenceSystem getCRS2D(Coverage coverage) throws TransformException
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
public static NoDataContainer getNoDataProperty(GridCoverage2D coverage)
Utility method for extracting NoData property from inputGridCoverage2D.- Returns:
- A
NoDataContainerobject containing input NoData definition
-
getROIProperty
public static ROI getROIProperty(GridCoverage2D coverage)
Utility method for extracting ROI property from inputGridCoverage2D.- Returns:
- A
ROIobject
-
setNoDataProperty
public static void setNoDataProperty(Map<String,Object> properties, Object noData)
Utility method for setting NoData to the inputMap- Parameters:
properties-Mapwhere the nodata will be setnoData- May be aRange,double[],doubleorNoDataContainer
-
setROIProperty
public static void setROIProperty(Map<String,Object> properties, ROI roi)
Utility method for setting ROI to the inputMap- Parameters:
properties-Mapwhere the ROI will be setroi-ROIinstance to set
-
getBackgroundValues
public static double[] getBackgroundValues(GridCoverage2D coverage)
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
public static boolean uses(GridCoverage coverage, RenderedImage image)
Returnstrueif the specified grid coverage or any of its source uses the following image.
-
getVisibleBand
public static int getVisibleBand(Object image)
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
public static boolean isScaleTranslate(MathTransform transform, double EPS)
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
public static double[] getResolution(AffineTransform gridToCRS)
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
public static boolean isSimpleGridToWorldTransform(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.- Parameters:
gridToCRS- an instance ofAffineTransformto check against.EPS- tolerance value for comparisons.- Returns:
trueif this transform is "simple",falseotherwise.
-
checkEmptySourceRegion
public static boolean checkEmptySourceRegion(ImageReadParam readParameters, Rectangle dimensions)
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
public static Number suggestNoDataValue(int dataType)
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
public static Properties loadPropertiesFromURL(URL propsURL)
Extract Properties from a specified URL
-
-