Skip to content

This sample shows how to apply a client-side rasterFunction to an instance of ImageryTileLayer.

The ImageryTileLayer in this sample contains Landsat 8 imagery of the Glacier National Park. When the application loads, the ImageryTileLayer will display the NDVI raster function result. Normalized Difference Vegetation Index (NDVI) is used to quantify vegetation greenness. It is useful in understanding vegetation density and assessing changes in vegetation health.

How it works

When the application loads, NDVI raster function is created. Then a Colormap function is created to display the result of the NDVI function. The colormap raster function is then applied to the ImageryTileLayer’s rasterFunction property as shown below.

// Create an NDVI raster function with output scaled to 0–255.
const ndviRasterFunction = {
functionName: "NDVI",
functionArguments: {
visibleBandID: 3,
infraredBandID: 4,
scientificOutput: false, // True outputs values from -1 to 1.
},
};
// Apply a predefined color map to the NDVI raster function result.
const rasterFunction = {
functionName: "Colormap",
functionArguments: { colormapName: NDVI3, raster: ndviRasterFunction },
};
// Initialize the layer with the last autocast RasterFunction in the chain.
const layer = new ImageryTileLayer({ url, rasterFunction });