jwo.landserf.process
Class RasterStats

java.lang.Object
  extended by jwo.landserf.process.RasterStats

public class RasterStats
extends Object

Allows summary statistics to be calculated from a raster map.

Version:
2.3, 3rd October, 2007.
Author:
Jo Wood

Field Summary
static int ALL_STATS
          Indicates that all summary statistics are to be calculated.
static int FRACD
          Indicates that only fractal dimension is to be calculated.
static int KURTOSIS
          Indicates that only kurtosis is to be calculated.
static int MEAN
          Indicates that only mean is to be calculated.
static int MEDIAN
          Indicates that only median is to be calculated.
static int MODE
          Indicates that only mode is to be calculated.
static int MODEF
          Indicates that only modal frequency is to be calculated.
static int MORAN
          Indicates that only Moran's I is to be calculated.
static int NUMVALS
          Indicates that only number of non-null cells is to be calculated.
static int PERCENTILE
          Indicates that a percentile value is to be calculated.
static int SKEW
          Indicates that only skewness is to be calculated.
static int STDEV
          Indicates that only standard deviation is to be calculated.
static int SUM
          Indicates that only the sum of all cells is to be calculated.
 
Constructor Summary
RasterStats(RasterMap raster)
          Initialises object with the given raster map and performs the calculations necessary to find all available summary statistics.
RasterStats(RasterMap raster, int stat)
          Initialises object with the given raster map and performs the calculations necessary to find the given summary statistics.
RasterStats(RasterMap raster, int stat, float percentile)
          Initialises object with the given raster map and performs the calculations necessary to find the given summary statistics and percentile.
 
Method Summary
 float getFractalD()
          Reports the fractal dimension (D) of the raster values.
 float getKurtosis()
          Reports the momental kurtosis of the raster values.
 float getMean()
          Reports the mean of the raster values.
 float getMedian()
          Reports the median of the raster values.
 float getMode()
          Reports the mode of the raster values.
 int getModeFrequency()
          Reports the frequency of the modal value of the raster.
 float[] getMoran()
          Reports the Moran's I spatial autocorrelation coefficients of the raster values.
 int getNumCells()
          Reports the total number of raster cells (including null values).
 int getNumNotNull()
          Reports the total number non-null raster values.
 int getNumNull()
          Reports the total number null raster values.
 float getPercentile()
          Reports the value whose percentile was defined in the constructor (defaults to median if not explicitly defined).
 float getSkew()
          Reports the momental skewness of the raster values.
 float getStdev()
          Reports the population standard deviation of the raster values.
 float getSum()
          Reports the sum of the raster values.
 float getVariogramGradient()
          Reports the gradient of the best fit line though the log-log variogram.
 float getVariogramIntercept()
          Reports the intercept of the best fit line though the log-log variogram.
 double[] getVariogramLogLags()
          Reports variogram x values (log of lags of paired samples).
 double[] getVariogramLogVariance()
          Reports variogram y values (log of variances of paired samples).
 float getVariogramRSquared()
          Reports the r-squared value of the best fit line though the log-log variogram.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEAN

public static final int MEAN
Indicates that only mean is to be calculated.

See Also:
Constant Field Values

NUMVALS

public static final int NUMVALS
Indicates that only number of non-null cells is to be calculated.

See Also:
Constant Field Values

SUM

public static final int SUM
Indicates that only the sum of all cells is to be calculated.

See Also:
Constant Field Values

MEDIAN

public static final int MEDIAN
Indicates that only median is to be calculated.

See Also:
Constant Field Values

MODE

public static final int MODE
Indicates that only mode is to be calculated.

See Also:
Constant Field Values

MODEF

public static final int MODEF
Indicates that only modal frequency is to be calculated.

See Also:
Constant Field Values

STDEV

public static final int STDEV
Indicates that only standard deviation is to be calculated.

See Also:
Constant Field Values

SKEW

public static final int SKEW
Indicates that only skewness is to be calculated.

See Also:
Constant Field Values

KURTOSIS

public static final int KURTOSIS
Indicates that only kurtosis is to be calculated.

See Also:
Constant Field Values

MORAN

public static final int MORAN
Indicates that only Moran's I is to be calculated.

See Also:
Constant Field Values

FRACD

public static final int FRACD
Indicates that only fractal dimension is to be calculated.

See Also:
Constant Field Values

PERCENTILE

public static final int PERCENTILE
Indicates that a percentile value is to be calculated.

See Also:
Constant Field Values

ALL_STATS

public static final int ALL_STATS
Indicates that all summary statistics are to be calculated.

See Also:
Constant Field Values
Constructor Detail

RasterStats

public RasterStats(RasterMap raster)
Initialises object with the given raster map and performs the calculations necessary to find all available summary statistics. This can involve some lengthy calculations for large rasters, so care should be taken when instantiating objects from this class.

Parameters:
raster - Raster map from which to calculate statistics.

RasterStats

public RasterStats(RasterMap raster,
                   int stat)
Initialises object with the given raster map and performs the calculations necessary to find the given summary statistics. This constructor allows calculations to be minimised in order calculate the given statistic. To calculate all statistics, stat should be set to ALL_STATS or the one-argument constructor. Note that this constructor assumes that if a percentile is required, it will be the 50%ile (median).

Parameters:
raster - Raster map from which to calculate statistics.
stat - Statistic to calculate (MEAN, MEDIAN etc.).

RasterStats

public RasterStats(RasterMap raster,
                   int stat,
                   float percentile)
Initialises object with the given raster map and performs the calculations necessary to find the given summary statistics and percentile. This constructor allows calculations to be minimised in order calculate the given statistic. To calculate all statistics, stat should be set to ALL_STATS or the other constructor called.

Parameters:
raster - Raster map from which to calculate statistics.
stat - Statistic to calculate (MEAN, MEDIAN etc.).
percentile - Percentile to calculate (0-100).
Method Detail

getNumCells

public int getNumCells()
Reports the total number of raster cells (including null values).

Returns:
Number of raster cells.

getNumNull

public int getNumNull()
Reports the total number null raster values.

Returns:
Number of null values.

getNumNotNull

public int getNumNotNull()
Reports the total number non-null raster values.

Returns:
Number of non-null values.

getMean

public float getMean()
Reports the mean of the raster values.

Returns:
Mean of raster values.

getSum

public float getSum()
Reports the sum of the raster values.

Returns:
Sum of raster values.

getMedian

public float getMedian()
Reports the median of the raster values.

Returns:
Median of raster values.

getPercentile

public float getPercentile()
Reports the value whose percentile was defined in the constructor (defaults to median if not explicitly defined).

Returns:
Percentile of raster values.

getMode

public float getMode()
Reports the mode of the raster values.

Returns:
Mode of raster values.

getModeFrequency

public int getModeFrequency()
Reports the frequency of the modal value of the raster. This is can be used to assess the validity of the mode (continuous measurement data are likely to have a maximum frequency of 1).

Returns:
Maximum frequency of any raster values.

getStdev

public float getStdev()
Reports the population standard deviation of the raster values.

Returns:
Standard deviation of raster values.

getSkew

public float getSkew()
Reports the momental skewness of the raster values.

Returns:
Skewness of raster values.

getKurtosis

public float getKurtosis()
Reports the momental kurtosis of the raster values.

Returns:
Kurtosis of raster values.

getMoran

public float[] getMoran()
Reports the Moran's I spatial autocorrelation coefficients of the raster values.

Returns:
Moran's I coefficients. 5 values are returned in the array holding the Moran's I in the following order: E-W variation, SE-NW variation, N-S variation, NE-SW variation and overall variation.

getFractalD

public float getFractalD()
Reports the fractal dimension (D) of the raster values. D is calculated by finding the best fit gradient of the log-log variogram of randomly drawn pairs from the raster.

Returns:
Fractal dimension of raster values.

getVariogramLogLags

public double[] getVariogramLogLags()
Reports variogram x values (log of lags of paired samples).

Returns:
Variogram x values.

getVariogramLogVariance

public double[] getVariogramLogVariance()
Reports variogram y values (log of variances of paired samples).

Returns:
Variogram y values.

getVariogramGradient

public float getVariogramGradient()
Reports the gradient of the best fit line though the log-log variogram.

Returns:
Variogram gradient.

getVariogramIntercept

public float getVariogramIntercept()
Reports the intercept of the best fit line though the log-log variogram.

Returns:
Variogram intercept (log(nugget)).

getVariogramRSquared

public float getVariogramRSquared()
Reports the r-squared value of the best fit line though the log-log variogram. This gives an indication of the reliability of the fractal dimension.

Returns:
R-squared value of best-fit line.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009