Class BilinearInterpolator


  • public class BilinearInterpolator
    extends Object
    Interpolates a grid to a grid of different dimensions using bilinear interpolation.

    NO_DATA cell values are supported in the source grid. There are two ways of handling the boundary between NO_DATA cells and data cells:

    • Truncate - If any source cell is NO_DATA, the dest value is NO_DATA. This is simple and fast, but does make the data boundaries look a bit ragged.
    • Smooth - If only one source cell is NO_DATA, the value is interpolated using the 3 valid values, across one-half of the interpolated cells. This smoothes off the boundary. If 2 or more source cells are NO_DATA, then Truncation is used.

    Reference: http://en.wikipedia.org/wiki/Bilinear_interpolation.

    Author:
    Martin Davis - OpenGeo
    • Constructor Detail

      • BilinearInterpolator

        public BilinearInterpolator​(float[][] src)
        Creates a new interpolator on a given source grid.
        Parameters:
        src - the source grid
      • BilinearInterpolator

        public BilinearInterpolator​(float[][] src,
                                    float noDataValue)
        Creates a new interpolator on a given source grid.
        Parameters:
        src - the source grid
        noDataValue - the NO_DATA value (if none use Float.NaN)
    • Method Detail

      • interpolate

        public float[][] interpolate​(int width,
                                     int height,
                                     boolean smoothBoundary)
        Interpolates the source grid to a new grid of different dimensions.
        Parameters:
        width - the width of the destination grid
        height - the height of the destination grid
        smoothBoundary - true if boundary smoothing should be performed
        Returns:
        the interpolated grid