|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.cv.SampleDimension
GridSampleDimension
in the org.geotools.coverage
package.
Describes the data values for a coverage. For a grid coverage a sample dimension is a band.
Sample values in a band may be organized in categories. This SampleDimension
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[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.
CV_SampleDimension
,
Serialized FormConstructor Summary | |
|
SampleDimension()
Deprecated. Construct a sample dimension with no category. |
|
SampleDimension(Category[] categories,
Unit units)
Deprecated. Constructs a sample dimension with an arbitrary set of categories, which may be both quantitative and qualitative. |
protected |
SampleDimension(SampleDimension other)
Deprecated. Constructs a new sample dimension with the same categories and units than the specified sample dimension. |
|
SampleDimension(java.lang.String[] names)
Deprecated. Constructs a sample dimension with a set of qualitative categories only. |
|
SampleDimension(java.lang.String[] names,
java.awt.Color[] colors)
Deprecated. Constructs a sample dimension with a set of qualitative categories only. |
|
SampleDimension(java.lang.String description,
SampleDimensionType type,
ColorInterpretation color,
java.awt.Color[] palette,
java.lang.String[] categories,
double[] nodata,
double minimum,
double maximum,
double scale,
double offset,
Unit unit)
Deprecated. Constructs a sample dimension with the specified properties. |
Method Summary | |
boolean |
equals(java.lang.Object object)
Deprecated. Compares the specified object with this sample dimension for equality. |
static SampleDimension |
fromGeoAPI(org.opengis.coverage.SampleDimension sd)
Deprecated. Mimic a GeoAPI interface as a legacy implementation. |
SampleDimension |
geophysics(boolean geo)
Deprecated. If true , returns the geophysics companion of this sample dimension. |
Category |
getBackground()
Deprecated. Returns a default category to use for background. |
java.util.List |
getCategories()
Deprecated. Returns all categories in this sample dimension. |
Category |
getCategory(double sample)
Deprecated. Returns the category for the specified sample value. |
java.lang.String[] |
getCategoryNames(java.util.Locale locale)
Deprecated. Returns a sequence of category names for the values contained in this sample dimension. |
ColorInterpretation |
getColorInterpretation()
Deprecated. Returns the color interpretation of the sample dimension. |
java.awt.image.ColorModel |
getColorModel()
Deprecated. Returns a color model for this sample dimension. |
java.awt.image.ColorModel |
getColorModel(int visibleBand,
int numBands)
Deprecated. Returns a color model for this sample dimension. |
java.awt.image.ColorModel |
getColorModel(int visibleBand,
int numBands,
int type)
Deprecated. Returns a color model for this sample dimension. |
java.lang.String |
getDescription(java.util.Locale locale)
Deprecated. Get the sample dimension title or description. |
java.lang.String |
getLabel(double value,
java.util.Locale locale)
Deprecated. Returns a string representation of a sample value. |
double |
getMaximumValue()
Deprecated. Returns the maximum value occurring in this sample dimension. |
double |
getMinimumValue()
Deprecated. Returns the minimum value occurring in this sample dimension. |
double[] |
getNoDataValue()
Deprecated. Returns the values to indicate "no data" for this sample dimension. |
double |
getOffset()
Deprecated. Returns the value to add to grid values for this sample dimension. |
NumberRange |
getRange()
Deprecated. Returns the range of values in this sample dimension. |
SampleDimensionType |
getSampleDimensionType()
Deprecated. Returns a code value indicating grid value data type. |
MathTransform1D |
getSampleToGeophysics()
Deprecated. Returns a transform from sample values to geophysics values. |
double |
getScale()
Deprecated. Returns the value which is multiplied to grid values for this sample dimension. |
Unit |
getUnits()
Deprecated. Returns the unit information for this sample dimension. |
int |
hashCode()
Deprecated. Returns a hash value for this sample dimension. |
SampleDimension |
rescale(double scale,
double offset)
Deprecated. Returns a sample dimension using new scale and offset
coefficients. |
java.lang.String |
toString()
Deprecated. Returns a string representation of this sample dimension. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SampleDimension()
public SampleDimension(java.lang.String[] names)
names
- Sequence of category names for the values contained in a sample dimension.
This allows for names to be assigned to numerical values. The first entry
in the sequence relates to a cell value of zero. For example:
[0]="Background", [1]="Water", [2]="Forest", [3]="Urban".public SampleDimension(java.lang.String[] names, java.awt.Color[] colors)
names
- Sequence of category names for the values contained in a sample dimension.
This allows for names to be assigned to numerical values. The first entry
in the sequence relates to a cell value of zero. For example:
[0]="Background", [1]="Water", [2]="Forest", [3]="Urban".colors
- Color to assign to each category. This array must have the same
length than names
.public SampleDimension(java.lang.String description, SampleDimensionType type, ColorInterpretation color, java.awt.Color[] palette, java.lang.String[] categories, double[] nodata, double minimum, double maximum, double scale, double offset, Unit unit)
double
primitive can be null
. This constructor
allows the construction of a SampleDimension
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
.
description
- The sample dimension title or description, or null
if none.
This is the value to be returned by getDescription(java.util.Locale)
.type
- The grid value data type (which indicate the number of bits for the data type),
or null
for computing it automatically from the range
[minimum..maximum]
. This is the value to be returned by
getSampleDimensionType()
.color
- The color interpretation, or null
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 null
for a default color palette (usually grayscale). If categories
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 null
if none. This is the values to be returned by
getCategoryNames(java.util.Locale)
.nodata
- the values to indicate "no data", or null
if none. This is the
values to be returned by getNoDataValue()
.minimum
- The lower value, inclusive. The [minimum..maximum]
range may or
may not includes the nodata
values; the range will be adjusted as
needed. If categories
was non-null, then minimum
is
usually 0. This is the value to be returned by getMinimumValue()
.maximum
- The upper value, inclusive as well. The
[minimum..maximum]
range may or may not includes the nodata
values; the range will be adjusted as needed. If categories
was non-null,
then maximum
is usually equals to categories.length-1
. 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 null
if none.
This is the value to be returned by getUnits()
.
java.lang.IllegalArgumentException
- if the range [minimum..maximum]
is not valid.public SampleDimension(Category[] categories, Unit units) throws java.lang.IllegalArgumentException
categories
- The list of categories.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.
java.lang.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 SampleDimension(SampleDimension other)
other
- The other sample dimension, or null
.Method Detail |
public SampleDimensionType getSampleDimensionType()
public java.lang.String getDescription(java.util.Locale locale)
null
if no description is present.
locale
- The locale, or null
for the default one.
null
if none.
If no description was available in the specified locale,
then a default locale is used.CV_SampleDimension.getDescription()
public java.lang.String[] getCategoryNames(java.util.Locale locale) throws java.lang.IllegalStateException
[0] Background [1] Water [2] Forest [3] Urban
locale
- The locale for category names, or null
for a default locale.
null
if there is no category in this sample dimension.
java.lang.IllegalStateException
- if a sequence can't be mapped because some category use
negative or non-integer sample values.CV_SampleDimension.getCategoryNames()
,
getCategories()
,
getCategory(double)
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 0
.
null
if none.getCategoryNames(java.util.Locale)
,
getCategory(double)
public Category getCategory(double sample)
null
.
sample
- The value (can be one of NaN
values).
null
if none.getCategories()
,
getCategoryNames(java.util.Locale)
public Category getBackground()
null
.public double[] getNoDataValue() throws java.lang.IllegalStateException
getSampleToGeophysics()
returns null
, then
getNoDataValue()
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 getNoDataValue()
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.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
.
null
if not applicable.
java.lang.IllegalStateException
- if some qualitative categories use a range of
non-integer values.CV_SampleDimension.getNoDataValue()
,
getSampleToGeophysics()
public double getMinimumValue()
Double.NEGATIVE_INFINITY
.
CV_SampleDimension.getMinimumValue()
,
getRange()
public double getMaximumValue()
Double.POSITIVE_INFINITY
.
CV_SampleDimension.getMaximumValue()
,
getRange()
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
quantitative category.Category.getRange()
,
getMinimumValue()
,
getMaximumValue()
public java.lang.String getLabel(double value, java.util.Locale locale)
value
maps a qualitative category, then the
category name is returned as of Category.getName(Locale)
.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 appened.
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.SampleDimension
returns null
if there is no
category or if an exception is thrown, but CategoryList
returns "Untitled" if the value is an unknow 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.
CV_SampleDimension.getUnits()
,
getSampleToGeophysics()
public double getOffset() throws java.lang.IllegalStateException
Together withoffset + scale*sample
getScale()
and getNoDataValue()
, 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
.
java.lang.IllegalStateException
- if the transform from sample to geophysics values
is not a linear relation.CV_SampleDimension.getOffset()
,
getSampleToGeophysics()
,
rescale(double, double)
public double getScale()
Together withoffset + scale*sample
getOffset()
and getNoDataValue()
, 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
.
java.lang.IllegalStateException
- if the transform from sample to geophysics values
is not a linear relation.CV_SampleDimension.getScale()
,
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 differenciate NaN
values to get back the original
sample value.
null
if this
sample dimension do not defines any transform (which is not the same that
defining an identity transform).getScale()
,
getOffset()
,
getNoDataValue()
,
rescale(double, double)
public SampleDimension geophysics(boolean geo)
true
, returns the geophysics companion of this sample dimension. By
definition, a geophysics sample dimension is a sample dimension with a
range of sample values transformed in such a way that the
sampleToGeophysics
transform is always the identity
transform, or null
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.
SampleDimension
objects live by pair: a geophysics one (used for
computation) and a non-geophysics one (used for packing 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 non-geophysics instance of the
pair. In other words, the result of geophysics(b1).geophysics(b2).geophysics(b3)
depends only on the value in the last call (b3
).
geo
- true
to get a sample dimension with an identity
transform and a range of
sample values matching the geophysics values, or false
to get back the
original sample dimension.
null
, but may be this
.Category.geophysics(boolean)
,
GridCoverage.geophysics(boolean)
public ColorInterpretation getColorInterpretation()
ColorInterpretation.UNDEFINED
.
CV_SampleDimension.getColorInterpretation()
public java.awt.image.ColorModel getColorModel()
Category.getColors()
.
The returned color model will typically use data type DataBuffer.TYPE_FLOAT
if this
SampleDimension
instance is "geophysics", or an integer data type otherwise.
GridCoverage.getSampleDimensions()
returns special
implementations of SampleDimension
. In this particular case, the color model
created by this getColorModel()
method will have the same number of bands
than the grid coverage's RenderedImage
.
RenderedImage
objects with values
in the getRange()
range. May be null
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
SampleDimension
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 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
for creating a multi-bands color
model. Logically, we would expect as many SampleDimension
s
as bands.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 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
for creating a multi-bands color
model. Logically, we would expect as many SampleDimension
s
as bands.public SampleDimension 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.geotools.ct.MathTransform1D)
public int hashCode()
public boolean equals(java.lang.Object object)
public java.lang.String toString()
public static SampleDimension fromGeoAPI(org.opengis.coverage.SampleDimension sd)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |