Datalens.ai
← All algorithms

INTERPOLATION

griddata

Convenience function for interpolating unstructured data in multiple dimensions.

Example of usage

Python API reference included; executable data demonstration pending review.

Usage / limitations

+Use when: Estimate values between samples.

−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.

Mathematical formula

See method documentation: implementation and assumptions vary.
Sample dataShow
{
  "variable": "observations",
  "domain": "Environmental monitoring — spatial weather stations",
  "feature_names": [
    "east_km",
    "north_km",
    "temperature_c"
  ],
  "stations": [
    {
      "east_km": 0,
      "north_km": 0,
      "temperature_c": 18.0
    },
    {
      "east_km": 0,
      "north_km": 1,
      "temperature_c": 19.0
    },
    {
      "east_km": 0,
      "north_km": 2,
      "temperature_c": 20.0
    },
    {
      "east_km": 1,
      "north_km": 0,
      "temperature_c": 20.0
    },
    {
      "east_km": 1,
      "north_km": 1,
      "temperature_c": 21.0
    },
    {
      "east_km": 1,
      "north_km": 2,
      "temperature_c": 22.0
    },
    {
      "east_km": 2,
      "north_km": 0,
      "temperature_c": 22.0
    },
    {
      "east_km": 2,
      "north_km": 1,
      "temperature_c": 23.0
    },
    {
      "east_km": 2,
      "north_km": 2,
      "temperature_c": 24.0
    }
  ]
}

Code example (Python)

# DataLens.ai example — griddata
# Domain: environmental temperature monitoring.
# Input observations is supplied by the Sample Data section.
import numpy as np
from scipy.interpolate import griddata

# Read recorded measurements with explicit, meaningful feature names.
# Perform the specified interpolation and validate expected properties.
points = np.array([[r["east_km"], r["north_km"]] for r in observations["stations"]], dtype=float)
values = np.array([r["temperature_c"] for r in observations["stations"]])
result = griddata(points, values, points, method="linear")
assert np.allclose(result, values, atol=1e-9)

# Self-test completed without raising an assertion error.
print("Expected output verified")