gis-tools-ts - v0.6.0
    Preparing search index...

    Function bilinearInterpolation

    • Bilinear Interpolation

      Given a reference of data, interpolate a point using bilinear interpolation

      import { bilinearInterpolation, getBilinearPoints, PointIndexFast } from 'gis-tools-ts';
      import type { VectorPoint } from 'gis-tools-ts';

      // We have m-value data that we want to interpolate
      interface TempData { temp: number; }

      const pointIndex = new PointIndexFast<TempData>();
      // add lots of points
      pointIndex.insertLonLat(lon, lat, data);
      // ....

      // given a point we are interested in
      const point: VectorPoint = { x: 20, y: -40 };
      // get a collection of points relative to the point
      const data = await pointIndex.searchRadius(point.x, point.y, radius);

      // interpolate
      const interpolatedValue = bilinearInterpolation<TempData>(point, data, (p) => p.m.temp);

      // if you reuse the same data, you can pass in the corners for performance gains
      const corners = getBilinearPoints(point, data);
      const interpolatedValue = bilinearInterpolation<TempData>(point, data, (p) => p.m.temp, corners);

      Type Parameters

      • T extends Properties = Properties

      Parameters

      • point: VectorPoint

        point to interpolate

      • refData: VectorPoint<T>[]

        reference data to interpolate from

      • getValue: GetInterpolateValue<T> = defaultGetInterpolateCurrentValue

        function to get value from reference data. Can be the z value or a property in the m-values defaults to function that returns the z value or 0 if the z value is undefined

      • Optionalcorners: BilinearCorners<T>

        the 4 corner points relative to the reference point. Add this if you don't want to keep recomputing the corners on the same data.

      Returns number

      • the interpolated value