|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectGridSampleDimension
@Immutable public class GridSampleDimension
Describes the data values for a coverage as a list of categories. For
a grid coverage a sample dimension is a band. Sample values in a band may be organized in
categories. This GridSampleDimension implementation is capable to differentiate
qualitative and quantitative categories. For example an image of sea surface
temperature (SST) could very well defines the following categories:
In this example, sample values in range[0] : no data [1] : cloud [2] : land [10..210] : temperature to be converted into Celsius degrees through a linear equation
[10..210] defines a quantitative category,
while all others categories are qualitative. The difference between those two kinds of category
is that the Category.getSampleToGeophysics() method returns a non-null transform if and
only if the category is quantitative.
While this class can be used with arbitrary coverage,
the primary target for this implementation is grid coverage storing their sample values as integers. This explain the "Grid" prefix
in the class name.
SampleDimensionPanel,
Serialized Form
| coverage/geotk-coverage (download) | View source code for this class |
| Constructor Summary | |
|---|---|
|
GridSampleDimension(CharSequence description)
Constructs a sample dimension with specified name and no category. |
|
GridSampleDimension(CharSequence description,
Category[] categories,
Unit<?> units)
Constructs a sample dimension with an arbitrary set of categories, which may be both quantitative and qualitative. |
|
GridSampleDimension(CharSequence description,
CharSequence[] categoriesNames)
Constructs a sample dimension with a set of qualitative categories only. |
|
GridSampleDimension(CharSequence description,
CharSequence[] names,
Color[] colors)
Constructs a sample dimension with a set of qualitative categories and colors. |
|
GridSampleDimension(CharSequence description,
SampleDimensionType type,
ColorInterpretation color,
Color[] palette,
CharSequence[] categories,
double[] nodata,
double minimum,
double maximum,
double scale,
double offset,
Unit<?> unit)
Constructs a sample dimension with the specified properties. |
protected |
GridSampleDimension(GridSampleDimension other)
Constructs a new sample dimension with the same categories and units than the specified sample dimension. |
| Method Summary | |
|---|---|
static GridSampleDimension |
castOrCopy(SampleDimension sd)
Returns the content of the given OpenGIS's sample dimension as a Geotk implementation of GridSampleDimension. |
boolean |
equals(Object object)
Compares the specified object with this sample dimension for equality. |
GridSampleDimension |
geophysics(boolean geo)
Returns the geophysics or packed view of this sample dimension. |
Category |
getBackground()
Returns a default category to use for background. |
List<Category> |
getCategories()
Returns all categories in this sample dimension. |
Category |
getCategory(double sample)
Returns the category for the specified sample value. |
InternationalString[] |
getCategoryNames()
Returns a sequence of category names for the values contained in this sample dimension. |
ColorInterpretation |
getColorInterpretation()
Deprecated. No replacement. |
ColorModel |
getColorModel()
Returns a color model for this sample dimension. |
ColorModel |
getColorModel(int visibleBand,
int numBands)
Returns a color model for this sample dimension. |
ColorModel |
getColorModel(int visibleBand,
int numBands,
int type)
Returns a color model for this sample dimension. |
InternationalString |
getDescription()
Gets the sample dimension title or description. |
String |
getLabel(double value,
Locale locale)
Returns a string representation of a sample value. |
double |
getMaximumValue()
Returns the maximum value occurring in this sample dimension (inclusive). |
double |
getMinimumValue()
Returns the minimum value occurring in this sample dimension (inclusive). |
double[] |
getNoDataValues()
Returns the values to indicate "no data" for this sample dimension. |
double |
getOffset()
Returns the value to add to grid values for this sample dimension. |
int[][] |
getPalette()
Deprecated. No replacement. |
PaletteInterpretation |
getPaletteInterpretation()
Deprecated. No replacement. |
NumberRange<?> |
getRange()
Returns the range of values in this sample dimension. |
SampleDimensionType |
getSampleDimensionType()
Returns a code value indicating grid value data type. |
MathTransform1D |
getSampleToGeophysics()
Returns the transfer function from sample values to geophysics values. |
double |
getScale()
Returns the value which is multiplied to grid values for this sample dimension. |
Unit<?> |
getUnits()
Returns the unit information for this sample dimension. |
int |
hashCode()
Returns a hash value for this sample dimension. |
boolean |
isRangeSigned()
Returns true if the range includes negative values. |
GridSampleDimension |
rescale(double scale,
double offset)
Returns a sample dimension using new scale and offset
coefficients. |
String |
toString()
Returns a string representation of this sample dimension. |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GridSampleDimension(CharSequence description)
description - The sample dimension title or description, or null if
none. This is the value to be returned by getDescription().
public GridSampleDimension(CharSequence description,
CharSequence[] categoriesNames)
description - The sample dimension title or description, or null for the default
(the name of what looks like the "main" category). This is the value to be
returned by getDescription().categoriesNames - Sequence of category names for the values contained in a sample dimension,
as String or InternationalString objects.
public GridSampleDimension(CharSequence description,
CharSequence[] names,
Color[] colors)
description - The sample dimension title or description, or null for the default
(the name of what looks like the "main" category). This is the value to be
returned by getDescription().names - Sequence of category names for the values contained in a sample dimension,
as String or InternationalString objects.colors - Color to assign to each category. This array must have the
same length than names.
public GridSampleDimension(CharSequence description,
SampleDimensionType type,
ColorInterpretation color,
Color[] palette,
CharSequence[] categories,
double[] nodata,
double minimum,
double maximum,
double scale,
double offset,
Unit<?> unit)
double primitive can be null, and
any char sequence can be either a String
or InternationalString object.
This constructor allows the construction of a GridSampleDimension without explicit
construction of Category objects. An heuristic approach is used for dispatching the
informations into a set of Category objects. However, this constructor still less
general and provides less fine-grain control than the constructor expecting an array of
Category objects.
The table below lists the methods which will return the parameters given to this constructor, together with their default value (from heuristic rules).
| Parameter | Returned by | Default value |
|---|---|---|
description |
getDescription() |
The name of what looks like the "main" category. |
type |
getSampleDimensionType() |
Computed automatically from the [minimum..maximum] range. |
color |
getColorInterpretation() |
Usually ColorInterpretation.PALETTE_INDEX. |
palette |
getColorModel() |
Usually grayscale. |
categories |
getCategoryNames() |
No category. |
nodata |
getNoDataValues() |
No pad value. |
minimum |
getMinimumValue() |
|
maximum |
getMaximumValue() |
|
scale |
getScale() |
|
offset |
getOffset() |
|
unit |
getUnits() |
description - The sample dimension title or description.type - The grid value data type (which indicate the number of bits for the data type).color - The color interpretation.palette - The color palette associated with the sample dimension. If categories is
non-null, then both arrays usually have the same length. However, this constructor
is tolerant about the array length.categories - A sequence of category names for the values contained in the sample dimension.nodata - The values to indicate "no data". The [minimum..maximum] range may or may
not includes the nodata values; the range will be adjusted as needed.minimum - The lower sample value, inclusive. If categories was non-null,
then minimum is usually 0.maximum - The upper sample value, inclusive as well. If categories
was non-null, then maximum is often equals to categories.length-1.scale - The value which is multiplied to grid values, or 1 if none.offset - The value to add to grid values, or 0 if none.unit - The unit information for this sample dimension.
IllegalArgumentException - if the range [minimum..maximum] is not valid.
public GridSampleDimension(CharSequence description,
Category[] categories,
Unit<?> units)
throws IllegalArgumentException
description - The sample dimension title or description, or null for the default
(the name of what looks like the "main" category). This is the value to be
returned by getDescription().categories - The list of categories, or null if none.units - The unit information for this sample dimension. May be null if
no category has units. This unit apply to values obtained after the
sampleToGeophysics transformation.
IllegalArgumentException - if categories contains incompatible categories. If
may be the case for example if two or more categories have
overlapping ranges of sample values.protected GridSampleDimension(GridSampleDimension other)
other - The other sample dimension, or null.| Method Detail |
|---|
public static GridSampleDimension castOrCopy(SampleDimension sd)
GridSampleDimension.
sd - The sample dimension to wrap into a Geotk implementation.
GridSampleDimension instance.public SampleDimensionType getSampleDimensionType()
getSampleDimensionType in interface SampleDimensionpublic InternationalString getDescription()
null if no description is present.
getDescription in interface SampleDimension
public InternationalString[] getCategoryNames()
throws IllegalStateException
[0] Background [1] Water [2] Forest [3] Urban
getCategoryNames in interface SampleDimensionnull if there is no category in this sample dimension.
IllegalStateException - if a sequence can't be mapped because some category use
negative or non-integer sample values.getCategories(),
getCategory(double)public List<Category> getCategories()
Category 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 value 0.
null if none.getCategoryNames(),
getCategory(double)public Category getCategory(double sample)
null.
sample - The value (can be one of NaN values).
null if none.getCategories(),
getCategoryNames()public Category getBackground()
null.
public double[] getNoDataValues()
throws IllegalStateException
getSampleToGeophysics() returns null, then getNoDataValues()
returns null as well. This means that this sample dimension contains no category
or contains only qualitative categories (e.g. a band from a classified image).getSampleToGeophysics() returns an identity transform, then
getNoDataValues() returns null. This means that sample value in this
sample dimension are already expressed in geophysics values and that all "no data"
values (if any) have already been converted into NaN values.NaN will be ignored.
Together with getOffset() and getScale(), this method provides a limited
way to transform sample values into geophysics values. However, the recommended way is to
use the sampleToGeophysics transform instead, which is more
general and take care of converting automatically "no data" values into NaN.
getNoDataValues in interface SampleDimensionnull if not applicable.
IllegalStateException - if some qualitative categories use a range of
non-integer values.getSampleToGeophysics()public double getMinimumValue()
Double.NEGATIVE_INFINITY.
getMinimumValue in interface SampleDimensiongetRange()public double getMaximumValue()
Double.POSITIVE_INFINITY.
getMaximumValue in interface SampleDimensiongetRange()public NumberRange<?> getRange()
NaN values. A NumberRange object
gives more informations than getMinimumValue() and getMaximumValue() methods
since it contains also the data type (integer, float, etc.) and inclusion/exclusion
informations.
null if this sample dimension has no
non-NaN value.Category.getRange(),
getMinimumValue(),
getMaximumValue()CategoryList.getRange() when selecting the
appropriate data type. TypeMap.getSampleDimensionType(Range) may be of
some help.public boolean isRangeSigned()
true if the range includes negative values. If
this sample dimension does not declare any quantitative category, then this method
returns false.
Some color models, especially IndexColorModel, support only unsigned integer.
For such color models, any SampleDimension for which this method return
true will require special handling.
true if the range includes negative values.
public String getLabel(double value,
Locale locale)
value maps a qualitative category, then the
category name is returned as of Category.getName().value maps a quantitative category, then the value is
transformed into a geophysics value as with the sampleToGeophysics transform, the result is formatted as a number and the unit
symbol is appended.
value - The sample value (can be one of NaN values).locale - Locale to use for formatting, or null for the default locale.
null if there is none.GridSampleDimension
returns null if there is no category or if an exception is thrown, but
CategoryList returns "Untitled" if the value is an unknown NaN, and try
to format the number anyway in other cases.public Unit<?> getUnits()
null
if this dimension has no units. This unit apply to values obtained after the
sampleToGeophysics transformation.
getUnits in interface SampleDimensiongetSampleToGeophysics()
public double getOffset()
throws IllegalStateException
Together withoffset + scale*sample
getScale() and getNoDataValues(), this method provides a
limited way to transform sample values into geophysics values. However, the recommended
way is to use the sampleToGeophysics transform instead,
which is more general and take care of converting automatically "no data" values
into NaN.
getOffset in interface SampleDimensionIllegalStateException - if the transform from sample to geophysics values
is not a linear relation.getSampleToGeophysics(),
rescale(double, double)public double getScale()
Together withoffset + scale*sample
getOffset() and getNoDataValues(), this method provides a
limited way to transform sample values into geophysics values. However, the recommended
way is to use the sampleToGeophysics transform instead,
which is more general and take care of converting automatically "no data" values
into NaN.
getScale in interface SampleDimensionIllegalStateException - if the transform from sample to geophysics values
is not a linear relation.getSampleToGeophysics(),
rescale(double, double)public MathTransform1D getSampleToGeophysics()
null. If all sample
values are already geophysics values (including NaN for "no data" values), then this
method returns an identity transform. Otherwise, this method returns a transform expecting
sample values as input and computing geophysics value as output. This transform will take
care of converting all "no data values" into
NaN values.
The sampleToGeophysics.inverse()
transform is capable to differentiate NaN values to get back the original
sample value.
getSampleToGeophysics in interface SampleDimensionnull
if this sample dimension do not defines any transform (which is not the same that
defining an identity transform).getScale(),
getOffset(),
getNoDataValues(),
rescale(double, double)public GridSampleDimension geophysics(boolean geo)
null if no such
transform existed in the first place. In other words, the range of sample values in all
categories maps directly the "real world" values
without the need for any transformation.
GridSampleDimension objects live by pair: a
geophysics one (used for
computation) and a packed one
(used for storing data, usually as integers). The geo argument specifies which
object from the pair is wanted, regardless if this method is invoked on the geophysics or
packed instance of the pair.
geo - true to get a sample dimension with an identity
transform and a range
of values matching the geophysics values, or false to get back the
packed sample dimension.
null, but may be this.Category.geophysics(boolean),
GridCoverage2D.view(org.geotoolkit.coverage.grid.ViewType)@Deprecated public int[][] getPalette()
null will be returned.
getPalette in interface SampleDimensiongetPaletteInterpretation(),
getColorInterpretation(),
IndexColorModel@Deprecated public PaletteInterpretation getPaletteInterpretation()
GRAY_INDEX
or PALETTE_INDEX.
A palette entry type can be Gray, RGB, CMYK or HLS.
getPaletteInterpretation in interface SampleDimension@Deprecated public ColorInterpretation getColorInterpretation()
ColorInterpretation.UNDEFINED.
getColorInterpretation in interface SampleDimensionpublic ColorModel getColorModel()
Category.getColors().
The returned color model will typically use DataBuffer.TYPE_FLOAT if this sample
dimension is geophysics, or
an integer data type otherwise.
Note that GridCoverage2D.getSampleDimension(int)
returns special implementations of GridSampleDimension. In this particular case,
the color model created by this getColorModel() method will have the same number
of bands than the grid coverage RenderedImage.
RenderedImage objects
with values in the getRange() range. May be null if this
sample dimension has no category.
public ColorModel getColorModel(int visibleBand,
int numBands)
Category.getColors(). The
returned color model will typically use DataBuffer.TYPE_FLOAT if this sample
dimension is geophysics,
or an integer data type otherwise.
visibleBand - The band to be made visible (usually 0). All other bands, if any
will be ignored.numBands - The number of bands for the color model (usually 1). The returned color
model will renderer only the visibleBand and ignore the others, but
the existence of all numBands will be at least tolerated. Supplemental
bands, even invisible, are useful for processing with Java Advanced Imaging.
RenderedImage objects
with values in the getRange() range. May be null if this
sample dimension has no category.SampleDimension object for creating a multi-bands color
model. Logically, we would expect as many SampleDimensions as bands.
public ColorModel getColorModel(int visibleBand,
int numBands,
int type)
Category.getColors().
visibleBand - The band to be made visible (usually 0). All other bands, if any
will be ignored.numBands - The number of bands for the color model (usually 1). The returned color
model will renderer only the visibleBand and ignore the others, but
the existence of all numBands will be at least tolerated. Supplemental
bands, even invisible, are useful for processing with Java Advanced Imaging.type - The data type that has to be used for the sample model.
RenderedImage objects
with values in the getRange() range. May be null if this
sample dimension has no category.SampleDimension object for creating a multi-bands color
model. Logically, we would expect as many SampleDimensions as bands.
public GridSampleDimension rescale(double scale,
double offset)
scale and offset
coefficients. Other properties like the sample value range,
no data values and colors
are unchanged.
scale - The value which is multiplied to grid values for the new sample dimension.offset - The value to add to grid values for the new sample dimension.
getScale(),
getOffset(),
Category.rescale(org.opengis.referencing.operation.MathTransform1D)public int hashCode()
hashCode in class Objectpublic boolean equals(Object object)
equals in class Objectobject - The object to compare with.
true if the given object is equals to this sample dimension.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||