public class BarnesSurfaceInterpolator extends ObjectInterpolates 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:
Eg = sum(wi * oi) / sum(wi)where
Egis the estimated surface value at the grid cell
wiis the weight value for the i'th observation point (see below for definition)
oiis the value of the i'th observation point
The weight (decay) function used is:
wi = exp(-di2 / L2c )where:
wiis the weight of the i'th observation point value
diis the distance from the grid cell being estimated to the i'th observation point
Lis 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.
cis 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.
Eg' = Eg + sum( wi * (oi - Ei) ) / sum( wi )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.
- Barnes, S. L (1964). "A technique for maximizing details in numerical weather-map analysis". Journal of Applied Meterology 3 (4): 396 - 409
- Martin Davis - OpenGeo
Fields Modifier and Type Field Description
DEFAULT_NO_DATA_VALUEThe default grid cell value used to indicate no data was computed for that cell
Constructors Constructor Description
BarnesSurfaceInterpolator(Coordinate observationData)Creates a Barnes Interpolator over a specified dataset of observation values.
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
computeSurface(Envelope srcEnv, int xSize, int ySize)Computes the estimated values for a regular grid of cells.
setConvergenceFactor(double convergenceFactor)Sets the convergence factor used during refinement passes.
setLengthScale(double lengthScale)Sets the length scale for the interpolation weighting function.
setMaxObservationDistance(double maxObsDistance)Sets the maximum distance from an observation for a grid point to be supported by that observation.
setMinObservationCount(int minObsCount)Sets the minimum number of in-range observations which are required for a grid point to be supported.
setNoData(float noDataValue)Sets the NO_DATA value used to indicate that a grid cell was not computed.
setPassCount(int passCount)Sets the number of passes performed during Barnes interpolation.
public static final float DEFAULT_NO_DATA_VALUEThe default grid cell value used to indicate no data was computed for that cell
- See Also:
- Constant Field Values
public BarnesSurfaceInterpolator(Coordinate observationData)Creates a Barnes Interpolator over a specified dataset of observation values. The observation data is provided as an array of
Coordinatevalues, where the X,Y ordinates are the observation location, and the Z ordinate contains the observation value.
observationData- the observed data values
public void setPassCount(int passCount)Sets the number of passes performed during Barnes interpolation.
passCount- the number of estimation passes to perform (1 or more)
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.
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.
convergenceFactor- the factor determining how much to refine the surface estimate
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.
maxObsDistance- the maximum distance from an observation for a supported grid point
public void setMinObservationCount(int minObsCount)Sets the minimum number of in-range observations which are required for a grid point to be supported. The default is 2.
minObsCount- the minimum in-range observation count for supported grid points
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.
noDataValue- the value to use to represent NO_DATA.
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 an
Envelope. The size of the grid is specified by the cell count for the grid width (X) and height (Y).
srcEnv- the area covered by the grid
xSize- the width of the grid
ySize- the height of the grid
- the computed grid of estimated data values (in row-major order)