Object
SampleDimension
- All Implemented Interfaces:
Serializable
Describes the data values in a coverage (the range). For a raster, a sample dimension is a band.
A sample dimension can reserve some values for qualitative information like “this
is a forest” and some other values for quantitative information like a temperature
measurements.
In this example, sample values in range [10…210] define a quantitative category, while all others categories are qualitative.
Example
An image of sea surface temperature (SST) could define the following categories:Values range | Meaning |
---|---|
[0] | No data |
[1] | Cloud |
[2] | Land |
[10…210] | Temperature to be converted into Celsius degrees through a linear equation |
Relationship with metadata
This class provides the same information than ISO 19115org.opengis.metadata.content.SampleDimension
,
but organized in a different way. The use of the same name may seem a risk, but those two types are typically
not used at the same time.
Definition of missing data
An important aspect of sample dimensions is the background value. It defines how to initialize an empty image or canvas with respect to the sample definition. It can be thought as the value for "lack of data" (fill value, no-data, missing value) category when the missing value cannot be categorized more precisely (cloud, instrument error, etc).- Since:
- 1.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A mutable builder for creating an immutableSampleDimension
. -
Constructor Summary
ConstructorDescriptionSampleDimension
(GenericName name, Number background, Collection<? extends Category> categories) Creates a sample dimension with the specified name and categories. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if some sample values can beNaN
values.boolean
Compares the specified object with this sample dimension for equality.forConvertedValues
(boolean converted) Returns a sample dimension that describes real values or sample values, depending ifconverted
istrue
orfalse
respectively.Returns the background value.Returns all categories in this sample dimension.Returns the range of values after conversions by the transfer function.getName()
Returns an identification for this sample dimension.Returns the values to indicate "no data" for this sample dimension.Optional
<NumberRange<?>> Returns the range of values occurring in this sample dimension.Returns the transfer function from sample values to real values.Returns the scale factor and offset of the transfer function.Returns the units of measurement for this sample dimension.int
Returns a hash value for this sample dimension.Returns a string representation of this sample dimension.static String
toString
(Locale locale, SampleDimension... dimensions) Returns a string representation of the given sample dimensions.
-
Constructor Details
-
SampleDimension
public SampleDimension(GenericName name, Number background, Collection<? extends Category> categories) Creates a sample dimension with the specified name and categories. The sample dimension name is used as a way to perform a band select by using human comprehensible descriptions instead of numbers. The background value is used for filling empty space in map reprojections. The background value (if specified) should be the value of a qualitative category present in thecategories
collection, but this is not mandatory.Note that
SampleDimension.Builder
provides a more convenient way to create sample dimensions.- Parameters:
name
- an identification for the sample dimension.background
- the background value, ornull
if none.categories
- the list of categories. May be empty if none.- Throws:
IllegalSampleDimensionException
- if two or more categories have overlapping sample value range.
-
-
Method Details
-
getName
Returns an identification for this sample dimension. This is typically used as a way to perform a band select by using human comprehensible descriptions instead of just numbers. Web Coverage Service (WCS) can use this name in order to perform band sub-setting as directed from a user request.- Returns:
- an identification of this sample dimension.
- See Also:
-
getCategories
Returns all categories in this sample dimension. Note that aCategory
object may apply to an arbitrary range of sample values. Consequently, the first element in this collection may not be directly related to the sample value0
.- Returns:
- the list of categories in this sample dimension, or an empty list if none.
-
getBackground
Returns the background value. This is the value used for filling empty spaces (e.g. in image corners) after a resampling operation. If this sample dimensions has quantitative categories, then the background value should be one of the value returned bygetNoDataValues()
. However, this is not mandatory.- Returns:
- the background value, typically (but not necessarily) one of
getNoDataValues()
.
-
getNoDataValues
Returns the values to indicate "no data" for this sample dimension. If the sample dimension describes converted values, then the "no data values" are NaN values.- Returns:
- the values to indicate no data values for this sample dimension, or an empty set if none.
- Throws:
IllegalStateException
- if this method cannot expand the range of no data values, for example because some ranges contain an infinite amount of values.- See Also:
-
getSampleRange
Returns the range of values occurring in this sample dimension. The range delimits sample values that can be converted into real values using the transfer function. If that function is identity, then the values are already real values and the range may be an instance ofMeasurementRange
(i.e. a number range with units of measurement).- Returns:
- the range of sample values in this sample dimension.
-
getMeasurementRange
Returns the range of values after conversions by the transfer function. This range is absent if there is no transfer function.- Returns:
- the range of values after conversion by the transfer function.
- See Also:
-
getTransferFunction
Returns the transfer function from sample values to real values. This method returns a transform expecting sample values as input and computing real values as output. The output units of measurement is given bygetUnits()
.This transform takes care of converting all "no data values" into
NaN
values. ThetransferFunction.inverse()
transform is capable to differentiate thoseNaN
values and get back the original sample value.- Returns:
- the transfer function from sample to real values. May be absent if this sample dimension does not define any transform (which is not the same that defining an identity transform).
-
getTransferFunctionFormula
Returns the scale factor and offset of the transfer function. The formula returned by this method does not take "no data values" in account. For a more generic transfer function, seegetTransferFunction()
.- Returns:
- a description of the part of the transfer function working on real numbers.
- Throws:
IllegalStateException
- if the transfer function cannot be simplified in a form representable byTransferFunction
.
-
getUnits
Returns the units of measurement for this sample dimension. This unit applies to values obtained after the transfer function. May be absent if not applicable.- Returns:
- the units of measurement.
- Throws:
IllegalStateException
- if this sample dimension use different units.- See Also:
-
allowsNaN
public boolean allowsNaN()Returnstrue
if some sample values can beNaN
values. It may be the case for converted values, but not necessarily (because a coverage does not necessarily allow missing values). Iftrue
, then the NaN values should be listed bygetNoDataValues()
.- Returns:
- whether some values in this sample dimension can be
NaN
. - Since:
- 1.1
- See Also:
-
forConvertedValues
Returns a sample dimension that describes real values or sample values, depending ifconverted
istrue
orfalse
respectively. If there is no transfer function, then this method returnsthis
.- Parameters:
converted
-true
for a sample dimension describing converted values, orfalse
for a sample dimension describing packed values.- Returns:
- a sample dimension describing converted or packed values, depending on
converted
argument value. May bethis
but nevernull
. - See Also:
-
hashCode
public int hashCode()Returns a hash value for this sample dimension. -
equals
Compares the specified object with this sample dimension for equality. -
toString
Returns a string representation of this sample dimension. This string is for debugging purpose only and may change in future version. -
toString
Returns a string representation of the given sample dimensions. This string is for debugging purpose only and may change in future version.- Parameters:
locale
- the locale to use for formatting texts.dimensions
- the sample dimensions to format.- Returns:
- a string representation of the given sample dimensions for debugging purpose.
-