Search code examples
openlayersopenlayers-6

IDW(Inverse Distance Weighted) Interpolation in openlayers (Custom Color palette)


Can someone provide me with an example on how to set my own custom colors with setData() from https://viglino.github.io/ol-ext/doc/doc-pages/ol.source.IDW.html on a IDW vector layer.

Thanks,


Solution

  • You have to overwrite the setData methode:

    idwSource.setData = function(v, data, i) {
      // Convert value to RGB
      data[i] = getRed (v);
      data[i+1] = getGreen (v);
      data[i+2] = getBlue (v);
      data[i+3] = 255;
    };