|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.coverage.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 implementation is capable to differenciate 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 defines a quantitative category, while all others categories are qualitative. The difference between those two kinds of category is that the[0] : no data [1] : cloud [2] : land [10..210] : temperature to be converted into Celsius degrees through a linear equation
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 "" prefix in the class name.
Constructor Summary | |
|
GridSampleDimension()
Constructs a sample dimension with no category. |
|
GridSampleDimension(Category[] categories,
javax.units.Unit units)
Constructs a sample dimension with an arbitrary set of categories, which may be both quantitative and qualitative. |
|
GridSampleDimension(java.lang.CharSequence[] names)
Constructs a sample dimension with a set of qualitative categories only. |
|
GridSampleDimension(java.lang.CharSequence[] names,
java.awt.Color[] colors)
Constructs a sample dimension with a set of qualitative categories and colors. |
|
GridSampleDimension(java.lang.CharSequence description,
org.opengis.coverage.SampleDimensionType type,
org.opengis.coverage.ColorInterpretation color,
java.awt.Color[] palette,
java.lang.CharSequence[] categories,
double[] nodata,
double minimum,
double maximum,
double scale,
double offset,
javax.units.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 | |
boolean |
equals(java.lang.Object object)
Compares the specified object with this sample dimension for equality. |
GridSampleDimension |
geophysics(boolean geo)
If , returns the geophysics companion of this sample dimension. |
Category |
getBackground()
Returns a default category to use for background. |
java.util.List |
getCategories()
Returns all categories in this sample dimension. |
Category |
getCategory(double sample)
Returns the category for the specified sample value. |
org.opengis.util.InternationalString[] |
getCategoryNames()
Returns a sequence of category names for the values contained in this sample dimension. |
java.lang.String[] |
getCategoryNames(java.util.Locale locale)
Deprecated. Use getCategoryNames() instead. |
org.opengis.coverage.ColorInterpretation |
getColorInterpretation()
Returns the color interpretation of the sample dimension. |
java.awt.image.ColorModel |
getColorModel()
Returns a color model for this sample dimension. |
java.awt.image.ColorModel |
getColorModel(int visibleBand,
int numBands)
Returns a color model for this sample dimension. |
java.awt.image.ColorModel |
getColorModel(int visibleBand,
int numBands,
int type)
Returns a color model for this sample dimension. |
org.opengis.util.InternationalString |
getDescription()
Get the sample dimension title or description. |
java.lang.String |
getDescription(java.util.Locale locale)
Deprecated. Use getDescription() instead. |
java.lang.String |
getLabel(double value,
java.util.Locale locale)
Returns a string representation of a sample value. |
double |
getMaximumValue()
Returns the maximum value occurring in this sample dimension. |
java.lang.String[] |
getMetaDataNames()
The list of metadata keywords for a sample dimension. |
java.lang.String |
getMetadataValue(java.lang.String name)
Retrieve the metadata value for a given metadata name. |
double |
getMinimumValue()
Returns the minimum value occurring in this sample dimension. |
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()
Color palette associated with the sample dimension. |
org.opengis.coverage.PaletteInterpretation |
getPaletteInterpretation()
Indicates the type of color palette entry for sample dimensions which have a palette. |
NumberRange |
getRange()
Returns the range of values in this sample dimension. |
org.opengis.coverage.SampleDimensionType |
getSampleDimensionType()
Returns a code value indicating grid value data type. |
org.opengis.referencing.operation.MathTransform1D |
getSampleToGeophysics()
Returns a transform from sample values to geophysics values. |
double |
getScale()
Returns the value which is multiplied to grid values for this sample dimension. |
javax.units.Unit |
getUnits()
Returns the unit information for this sample dimension. |
int |
hashCode()
Returns a hash value for this sample dimension. |
GridSampleDimension |
rescale(double scale,
double offset)
Returns a sample dimension using new scale and offset
coefficients. |
java.lang.String |
toString()
Returns a string representation of this sample dimension. |
static GridSampleDimension |
wrap(org.opengis.coverage.SampleDimension sd)
Wrap the specified OpenGIS's sample dimension into a Geotools's implementation of . |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GridSampleDimension()
public GridSampleDimension(java.lang.CharSequence[] names)
names
- Sequence of category names for the values contained in a sample dimension,
as String
or InternationalString
objects.public GridSampleDimension(java.lang.CharSequence[] names, java.awt.Color[] colors)
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 .public GridSampleDimension(java.lang.CharSequence description, org.opengis.coverage.SampleDimensionType type, org.opengis.coverage.ColorInterpretation color, java.awt.Color[] palette, java.lang.CharSequence[] categories, double[] nodata, double minimum, double maximum, double scale, double offset, javax.units.Unit unit)
String
or InternationalString
object.
This constructor allows the construction of a 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.
description
- The sample dimension title or description, or if none.
This is the value to be returned by getDescription()
.type
- The grid value data type (which indicate the number of bits for the data type),
or for computing it automatically from the range
. This is the value to be returned by
getSampleDimensionType()
.color
- The color interpretation, or for a default value (usually
PALETTE_INDEX
). This is the value to be
returned by getColorInterpretation()
.palette
- The color palette associated with the sample dimension, or
for a default color palette (usually grayscale). If is
non-null, then both arrays usually have the same length. However, this constructor
is tolerant on this array length. This is the value to be returned (indirectly) by
getColorModel()
.categories
- A sequence of category names for the values contained in the sample
dimension, or if none. This is the values to be returned by
getCategoryNames()
.nodata
- the values to indicate "no data", or if none. This is the
values to be returned by getNoDataValues()
.minimum
- The lower value, inclusive. The range may or
may not includes the values; the range will be adjusted as
needed. If was non-null, then is
usually 0. This is the value to be returned by getMinimumValue()
.maximum
- The upper value, inclusive as well. The
range may or may not includes the
values; the range will be adjusted as needed. If was non-null,
then is usually equals to . This
is the value to be returned by getMaximumValue()
.scale
- The value which is multiplied to grid values, or 1 if none. This is the value
to be returned by getScale()
.offset
- The value to add to grid values, or 0 if none. This is the value to be
returned by getOffset()
.unit
- The unit information for this sample dimension, or if none.
This is the value to be returned by getUnits()
.
java.lang.IllegalArgumentException
- if the range is not valid.public GridSampleDimension(Category[] categories, javax.units.Unit units) throws java.lang.IllegalArgumentException
categories
- The list of categories.units
- The unit information for this sample dimension.
May be if no category has units.
This unit apply to values obtained after the
sampleToGeophysics
transformation.
java.lang.IllegalArgumentException
- if 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 .Method Detail |
public static GridSampleDimension wrap(org.opengis.coverage.SampleDimension sd)
sd
- The sample dimension to wrap into a Geotools implementation.public org.opengis.coverage.SampleDimensionType getSampleDimensionType()
getSampleDimensionType
in interface org.opengis.coverage.SampleDimension
public org.opengis.util.InternationalString getDescription()
getDescription
in interface org.opengis.coverage.SampleDimension
public java.lang.String getDescription(java.util.Locale locale)
getDescription()
instead.
public org.opengis.util.InternationalString[] getCategoryNames() throws java.lang.IllegalStateException
[0] Background [1] Water [2] Forest [3] Urban
getCategoryNames
in interface org.opengis.coverage.SampleDimension
java.lang.IllegalStateException
- if a sequence can't be mapped because some category use
negative or non-integer sample values.getCategories()
,
getCategory(double)
public final java.lang.String[] getCategoryNames(java.util.Locale locale) throws java.lang.IllegalStateException
getCategoryNames()
instead.
java.lang.IllegalStateException
public java.util.List 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 .
getCategoryNames()
,
getCategory(double)
public Category getCategory(double sample)
sample
- The value (can be one of values).
getCategories()
,
getCategoryNames()
public Category getBackground()
public double[] getNoDataValues() throws java.lang.IllegalStateException
getSampleToGeophysics()
returns , then
returns 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 returns .
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 values.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 .
getNoDataValues
in interface org.opengis.coverage.SampleDimension
java.lang.IllegalStateException
- if some qualitative categories use a range of
non-integer values.getSampleToGeophysics()
public double getMinimumValue()
Double.NEGATIVE_INFINITY
.
getMinimumValue
in interface org.opengis.coverage.SampleDimension
getRange()
public double getMaximumValue()
Double.POSITIVE_INFINITY
.
getMaximumValue
in interface org.opengis.coverage.SampleDimension
getRange()
public NumberRange getRange()
NumberRange
object
gives more informations than getMinimumValue()
and getMaximumValue()
methods
since it contains also the data type (integer, float, etc.) and inclusion/exclusion
informations.
Category.getRange()
,
getMinimumValue()
,
getMaximumValue()
TypeMap.getSampleDimensionType(Range)
may be of some help.public java.lang.String getLabel(double value, java.util.Locale locale)
Category.getName()
.sampleToGeophysics
transform, the result is formatted as a number and the unit
symbol is appened.
value
- The sample value (can be one of values).locale
- Locale to use for formatting, or for the default locale.
public javax.units.Unit getUnits()
sampleToGeophysics
transformation.
getUnits
in interface org.opengis.coverage.SampleDimension
getSampleToGeophysics()
public double getOffset() throws java.lang.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 .
getOffset
in interface org.opengis.coverage.SampleDimension
java.lang.IllegalStateException
- 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 .
getScale
in interface org.opengis.coverage.SampleDimension
java.lang.IllegalStateException
- if the transform from sample to geophysics values
is not a linear relation.getSampleToGeophysics()
,
rescale(double, double)
public org.opengis.referencing.operation.MathTransform1D getSampleToGeophysics()
sampleToGeophysics.inverse()
transform is capable to differenciate values to get back the original
sample value.
getSampleToGeophysics
in interface org.opengis.coverage.SampleDimension
getScale()
,
getOffset()
,
getNoDataValues()
,
rescale(double, double)
public GridSampleDimension geophysics(boolean geo)
sampleToGeophysics
transform is always the identity
transform, or if no such transform existed in the first place. In
other words, the range of sample values in all category maps directly the "real world"
values without the need for any transformation.
objects live by pair: a geophysics one (used for computation) and a non-geophysics one (used for packing data, usually as integers). The argument specifies which object from the pair is wanted, regardless if this method is invoked on the geophysics or non-geophysics instance of the pair. In other words, the result of depends only on the value in the last call ().
geo
- to get a sample dimension with an identity
transform and a range of
sample values matching the geophysics values, or to get back the
original sample dimension.
Category.geophysics(boolean)
,
GridCoverage2D.geophysics(boolean)
public int[][] getPalette()
getPalette
in interface org.opengis.coverage.SampleDimension
getPaletteInterpretation()
,
getColorInterpretation()
,
IndexColorModel
public org.opengis.coverage.PaletteInterpretation getPaletteInterpretation()
GRAY_INDEX
or PALETTE_INDEX
.
A palette entry type can be Gray, RGB, CMYK or HLS.
getPaletteInterpretation
in interface org.opengis.coverage.SampleDimension
public org.opengis.coverage.ColorInterpretation getColorInterpretation()
ColorInterpretation.UNDEFINED
.
getColorInterpretation
in interface org.opengis.coverage.SampleDimension
public java.awt.image.ColorModel getColorModel()
Category.getColors()
.
The returned color model will typically use data type DataBuffer.TYPE_FLOAT
if this
instance is "geophysics", or an integer data type otherwise.
Note that GridCoverage2D.getSampleDimension(int)
returns
special implementations of . In this particular case,
the color model created by this method will have the same number of
bands than the grid coverage's RenderedImage
.
RenderedImage
objects with values
in the getRange()
range. May be if this
sample dimension has no category.public java.awt.image.ColorModel getColorModel(int visibleBand, int numBands)
Category.getColors()
. The
returned color model will typically use data type DataBuffer.TYPE_FLOAT
if this
instance 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 and ignore the others, but
the existence of all 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 if this
sample dimension has no category.public java.awt.image.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 and ignore the others, but
the existence of all 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 if this
sample dimension has no category.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 java.lang.String[] getMetaDataNames()
getMetaDataNames
in interface org.opengis.coverage.SampleDimension
getMetadataValue(java.lang.String)
,
PropertySource.getPropertyNames()
public java.lang.String getMetadataValue(java.lang.String name) throws org.opengis.coverage.MetadataNameNotFoundException
getMetadataValue
in interface org.opengis.coverage.SampleDimension
name
- Metadata keyword for which to retrieve metadata.
org.opengis.coverage.MetadataNameNotFoundException
- if there is no value for the specified metadata name.getMetaDataNames()
,
PropertySource.getProperty(java.lang.String)
public int hashCode()
public boolean equals(java.lang.Object object)
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |