jaitools.media.jai.zonalstats
Class ZonalStats

java.lang.Object
  extended by jaitools.media.jai.zonalstats.ZonalStats

public class ZonalStats
extends java.lang.Object

Holds the results of the ZonalStats operator. An instance of this class is stored as a property of the destination image.

Chaining methods are provided to select a subset of the results...


 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();
     }
 }

 

Since:
1.0
Version:
$Id: ZonalStats.java 1100 2010-02-10 07:28:08Z michael.bedward $
Author:
Michael Bedward
See Also:
Result, ZonalStatsDescriptor

Method Summary
 ZonalStats band(int b)
          Get the subset of results for the given band.
 java.util.SortedSet<java.lang.Integer> getZones()
          Get the integer IDs read from the zone image.
 java.util.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

getZones

public java.util.SortedSet<java.lang.Integer> getZones()
Get the integer IDs read from the zone image. If a zone image was not used all results are treated as being in zone 0.

Note that statistics will not necessarily have been calculated for all zones.

Returns:
the sorted zone IDs

band

public ZonalStats band(int b)
Get the subset of results for the given band. See the example of chaining this method in the class docs.

Parameters:
b - band index
Returns:
a new ZonalStats object containing results for the band (data are shared with the source object rather than copied)

zone

public ZonalStats zone(int z)
Get the subset of results for the given zone. See the example of chaining this method in the class docs.

Parameters:
z - zone ID
Returns:
a new ZonalStats object containing results for the zone (data are shared with the source object rather than copied)

statistic

public ZonalStats statistic(Statistic s)
Get the subset of results for the given Statistic. See the example of chaining this method in the class docs.

Parameters:
s - the statistic
Returns:
a new ZonalStats object containing results for the statistic (data are shared with the source object rather than copied)

results

public java.util.List<Result> results()
Returns the list of Result objects.

Returns:
the results
See Also:
Result


Copyright © 2009-2010. All Rights Reserved.