hongfaqiu / TIFFImageryProvider

Load GeoTIFF/COG(Cloud optimized GeoTIFF) on Cesium
https://tiff-imagery-provider.opendde.com/?panel=layer
MIT License
52 stars 10 forks source link

Mulitband raster algebra #7

Closed ilyaly closed 1 year ago

ilyaly commented 1 year ago

In the version 2.2.1 an expression parameter has been added to single rendering mode allowing to perform raster algebra with a selected band before rendering.

If I may I would like to suggest that it would be just great to have an ability to perform raster algebra operations with several band of a .tiff file in future versions. This feature will open unlimited possibilities for agriculture, forestry, ecology and users from other industries who are used to work with indexes like NDVI / NDRE e.t.c.

hongfaqiu commented 1 year ago

Thank you for your constructive feedback. In fact, I haven't tested the validity of the expression. This expression is not limited to a single band. You can use (b1 - b2)/(b1+b2) to calculate NDVI, but you need to fill in the value range of the color ramp stretching, which is the domain parameter.

Here's an example:

// NDVI
new TIFFImageryProvider({
  url: YOUR_TIFF_URL,
  renderOptions: {
    single: {
      colorScale: 'rainbow',
      domain: [-1, 1],
      expression: '(b1 - b2) / (b1 + b2)'
    }
  }
});
ilyaly commented 1 year ago

Great, thanks!