org.geotools.process.vector

## 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:

``` Eg = sum(wi * oi) / sum(wi)
```
where
• `Eg` is the estimated surface value at the grid cell
• `wi` is the weight value for the i'th observation point (see below for definition)
• `oi` is the value of the i'th observation point

The weight (decay) function used is:

``` wi = exp(-di2 / L2c )
```
where:
• `wi` is the weight of the i'th observation point value
• `di` is the distance from the grid cell being estimated to the i'th observation point
• `L` 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.
During refinement passes the value at each grid cell is re-estimated as:
```  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.

References

1. Barnes, S. L (1964). "A technique for maximizing details in numerical weather-map analysis". Journal of Applied Meterology 3 (4): 396 - 409
Author:
Martin Davis - OpenGeo
• ### Field Summary

Fields
Modifier and Type Field and 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 and Description
`BarnesSurfaceInterpolator(Coordinate[] observationData)`
Creates a Barnes Interpolator over a specified dataset of observation values.
• ### Method Summary

All Methods
Modifier and Type Method and 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 in-range 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.
• ### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### 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 of `Coordinate` 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 in-range observations which are required for a grid point to be supported. The default is 2.
Parameters:
`minObsCount` - the minimum in-range 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 an `Envelope`. 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 grid
`xSize` - the width of the grid
`ySize` - the height of the grid
Returns:
the computed grid of estimated data values (in row-major order)

Copyright © 1996–2022 Geotools. All rights reserved.