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

    Function averageInterpolation

    • Average Neighbor Interpolation

      Finds the avarage point in the reference data to the given point and returns its value.

      import { averageInterpolation, 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 = averageInterpolation<TempData>(point, data, (p) => p.m.temp);

      Type Parameters

      • T extends Properties = Properties

      Parameters

      • _point: VectorPoint

        Point to interpolate around. Unused for this method

      • refData: VectorPoint<T>[]

        Reference data to search from

      • getValue: GetInterpolateValue<T> = defaultGetInterpolateCurrentValue

        Function to get value from reference data defaults to function that returns the z value or 0 if the z value is undefined

      Returns number

      • The avarage value of the collection of points