|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjaitools.media.jai.zonalstats.ZonalStats
public class ZonalStats
Holds the results of the ZonalStats operator. An instance of this class is stored as a property of the destination image.
The result for each combination of data image band, zone image integer zone (if
provided) and requested statistic is stored as a Result object.
The most basic usage is to iterate through the results as follows...
RenderedOp op = JAI.create("zonalstats", myParamBlock);
ZonalStats allStats = (ZonalStats) op.getProperty(ZonalStatsDescriptor.ZONAL_STATS_PROPERTY);
for (Result r : allStats.results()) {
System.out.prinln(r);
}
Alternatively, the attributes of Result objects can be retrieved selectively...
ZonalStats allStats = ...
for (Result r : allStats.results()) {
if (r.getStatistic() == Statistic.MEAN) {
System.out.printf("%4d %4d %8.4f\n",
r.getImageBand(), r.getZone(), r.getValue());
}
}
For most uses it may be easier to use the chaining methods provided by ZonalStats
to select the subset of results required...
ZonalStats allStats = ...
// Get results for a given band
int bandIndex = ...
List bandResults = allStats.band(bandIndex).results();
// Get Statistic.MEAN values for the specified band and zone
List subsetResults = allStats.band(b).zone(z).statistic(Statistic.MEAN).results();
// Impress your friends with pretty printing !
Statistic[] statistics = {
Statistic.MIN,
Statistic.MAX,
Statistic.MEDIAN,
Statistic.APPROX_MEDIAN,
Statistic.SDEV
};
System.out.println(" exact approx");
System.out.println(" band zone min max median median sdev");
System.out.println("-----------------------------------------------------------");
for (int b : allStats.getImageBands()) {
for (int z : zs.getZones()) {
System.out.printf(" %4d %4d", b, z);
ZonalStats subset = zs.band(b).zone(z);
for (Statistic s : statistics) {
System.out.printf(" %8.4f", zoneSubset.statistic(s).results().get(0).getValue());
}
System.out.println();
}
}
Result,
ZonalStatsDescriptor| Method Summary | |
|---|---|
ZonalStats |
band(int b)
Get the subset of results for the given band. |
SortedSet<Integer> |
getZones()
Get the integer IDs read from the zone image. |
ZonalStats |
ranges(List<Range> ranges)
Get the subset of results for the given Ranges. |
List<Result> |
results()
Returns the list of Result objects. |
ZonalStats |
statistic(Statistic s)
Get the subset of results for the given Statistic. |
ZonalStats |
zone(int z)
Get the subset of results for the given zone. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public SortedSet<Integer> getZones()
Note that statistics will not necessarily have been calculated for all zones.
public ZonalStats band(int b)
b - band index
ZonalStats object containing results for the band
(data are shared with the source object rather than copied)public ZonalStats zone(int z)
z - zone ID
ZonalStats object containing results for the zone
(data are shared with the source object rather than copied)public ZonalStats statistic(Statistic s)
Statistic.
See the example of chaining this method in the class docs.
s - the statistic
ZonalStats object containing results for the statistic
(data are shared with the source object rather than copied)public ZonalStats ranges(List<Range> ranges)
Ranges.
ranges - the Ranges
ZonalStats object containing results for the ranges
(data are shared with the source object rather than copied)public List<Result> results()
Result objects.
Result
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||