Class BarnesSurfaceInterpolator
 Object

 BarnesSurfaceInterpolator

public class BarnesSurfaceInterpolator extends Object
Interpolates a surface across a regular grid from an irregular set of data points using the Barnes Surface Interpolation technique.Barnes Surface Interpolation is a surface estimating method commonly used as an interpolation technique for meteorological datasets. The algorithm operates on a regular grid of cells covering a specified extent in the input data space. It computes an initial pass to produce an averaged (smoothed) value for each cell in the grid, based on the cell's proximity to the points in the input observations. Subsequent refinement passes may be performed to improve the surface estimate to better approximate the observed values.
 The initial pass produces an averaged (smoothed) value for each grid cell using a summation of exponential (Gaussian) decay functions around each observation point.
 Subsequent refinement passes compute an error surface in the same way, using the deltas between the previous estimated surface and the observations. The error surface is added to the previous estimated surface to refine the estimate (by reducing the delta between the estimate and the observations).
For the first pass, the estimated value at each grid cell is:
E_{g} = sum(w_{i} * o_{i}) / sum(w_{i})
whereE_{g}
is the estimated surface value at the grid cellw_{i}
is the weight value for the i'th observation point (see below for definition)o_{i}
is the value of the i'th observation point
The weight (decay) function used is:
w_{i} = exp(d_{i}^{2} / L^{2}c )
where:w_{i}
is the weight of the i'th observation point valued_{i}
is the distance from the grid cell being estimated to the i'th observation pointL
is the length scale, which is determined by the observation spacing and the natural scale of the phenomena being measured. The length scale is in the units of the coordinate system of the data points. It will likely need to be empirically estimated.c
is the convergence factor, which controls how much refinement takes place during each refinement step. In the first pass the convergence is automatically set to 1. For subsequent passes a value in the range 0.2  0.3 is usually effective.
E_{g}' = E_{g} + sum( w_{i} * (o_{i}  E_{i}) ) / sum( w_{i} )
To optimize performance for large input datasets, it is only necessary to provide the data points which affect the surface interpolation within the specified output extent. In order to avoid "edge effects", the provided data points should be taken from an area somewhat larger than the output extent. The extent of the data area depends on the length scale, convergence factor, and data spacing in a complex way. A reasonable heuristic for determining the size of the query extent is to expand the output extent by a value of 2L.Since the visual quality and accuracy of the computed surface is lower further from valid observations, the algorithm allows limiting the extent of the computed cells. This is done by using the concept of supported grid cells. Grid cells are supported by the input observations if they are within a specified distance of a specified number of observation points. Grid cells which are not supported are not computed and are output as NO_DATA values.
References
 Barnes, S. L (1964). "A technique for maximizing details in numerical weathermap analysis". Journal of Applied Meterology 3 (4): 396  409
 Author:
 Martin Davis  OpenGeo


Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_NO_DATA_VALUE
The default grid cell value used to indicate no data was computed for that cell

Constructor Summary
Constructors Constructor Description BarnesSurfaceInterpolator(Coordinate[] observationData)
Creates a Barnes Interpolator over a specified dataset of observation values.

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float[][]
computeSurface(Envelope srcEnv, int xSize, int ySize)
Computes the estimated values for a regular grid of cells.void
setConvergenceFactor(double convergenceFactor)
Sets the convergence factor used during refinement passes.void
setLengthScale(double lengthScale)
Sets the length scale for the interpolation weighting function.void
setMaxObservationDistance(double maxObsDistance)
Sets the maximum distance from an observation for a grid point to be supported by that observation.void
setMinObservationCount(int minObsCount)
Sets the minimum number of inrange observations which are required for a grid point to be supported.void
setNoData(float noDataValue)
Sets the NO_DATA value used to indicate that a grid cell was not computed.void
setPassCount(int passCount)
Sets the number of passes performed during Barnes interpolation.



Field Detail

DEFAULT_NO_DATA_VALUE
public static final float DEFAULT_NO_DATA_VALUE
The default grid cell value used to indicate no data was computed for that cell See Also:
 Constant Field Values


Constructor Detail

BarnesSurfaceInterpolator
public BarnesSurfaceInterpolator(Coordinate[] observationData)
Creates a Barnes Interpolator over a specified dataset of observation values. The observation data is provided as an array ofCoordinate
values, where the X,Y ordinates are the observation location, and the Z ordinate contains the observation value. Parameters:
observationData
 the observed data values


Method Detail

setPassCount
public void setPassCount(int passCount)
Sets the number of passes performed during Barnes interpolation. Parameters:
passCount
 the number of estimation passes to perform (1 or more)

setLengthScale
public void setLengthScale(double lengthScale)
Sets the length scale for the interpolation weighting function. The length scale is determined from the distance between the observation points, as well as the scale of the phenomena which is being measured.

setConvergenceFactor
public void setConvergenceFactor(double convergenceFactor)
Sets the convergence factor used during refinement passes. The value should be in the range [0,1]. Empirically, values between 0.2  0.3 are most effective. Smaller values tend to make the interpolated surface too "jittery". Larger values produce less refinement effect. Parameters:
convergenceFactor
 the factor determining how much to refine the surface estimate

setMaxObservationDistance
public void setMaxObservationDistance(double maxObsDistance)
Sets the maximum distance from an observation for a grid point to be supported by that observation. Empirically determined; a reasonable starting point is between 1.5 and 2 times the Length scale. If the value is 0 (which is the default), all grid points are considered to be supported, and will thus be computed. Parameters:
maxObsDistance
 the maximum distance from an observation for a supported grid point

setMinObservationCount
public void setMinObservationCount(int minObsCount)
Sets the minimum number of inrange observations which are required for a grid point to be supported. The default is 2. Parameters:
minObsCount
 the minimum inrange observation count for supported grid points

setNoData
public void setNoData(float noDataValue)
Sets the NO_DATA value used to indicate that a grid cell was not computed. This value should be distinct from any potential data value. Parameters:
noDataValue
 the value to use to represent NO_DATA.

computeSurface
public float[][] computeSurface(Envelope srcEnv, int xSize, int ySize)
Computes the estimated values for a regular grid of cells. The area covered by the grid is specified by anEnvelope
. The size of the grid is specified by the cell count for the grid width (X) and height (Y). Parameters:
srcEnv
 the area covered by the gridxSize
 the width of the gridySize
 the height of the grid Returns:
 the computed grid of estimated data values (in rowmajor order)

