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 raster
property as shown below.
// NDVI raster function where the output will be between 0-255
const ndvi = new RasterFunction({
functionName: "NDVI",
functionArguments: {
visibleBandID: 3,
infraredBandID: 4,
scientificOutput: false // when true -1 to 1
}
});
// Apply a color map to the NDVI raster function result
// use one of the predefined NDVI color map.
const colormap = new RasterFunction({
functionName: "Colormap",
functionArguments: {
colormapName: rasterFunctionConstants.colormapName.NDVI3, // //NDVI and NDVI2
raster: ndvi
}
});
// apply the client-side raster function to the imagery layer.
const layer = new ImageryTileLayer({
url: "https://tiledimageservices.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Glacier_landsat_8/ImageServer",
rasterFunction: colormap
});