Hello,
I have an image service ( mosaic of time dimensional imagery). I want to apply the Minus function (subtraction) to two slices from the image service and display the output. How do I do this?
I would also like to do change detection using the same two slices, please suggest how to go about it?
I have provided the code that I am currently using to do the above but the result is incorrect, please help!
I am using ArcGIS JS API 4.22
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/support/MosaicRule",
"esri/layers/ImageryLayer",
"esri/layers/support/RasterFunction",
"esri/layers/support/ImageParameters",
"esri/layers/MapImageLayer"
], (Map, MapView, MosaicRule, ImageryLayer, RasterFunction, ImageParameters, MapImageLayer) => {
const year1 = "Reclass_IntYear2015";
const mr1 = new MosaicRule({
where: "name='" + year1 + "'"
});
const year2 = "Reclass_IntYear2020";
const mr2 = new MosaicRule({
where: "name='" + year2 + "'"
});
const layer1 = new ImageryLayer({
url: imageServiceURL,
mosaicRule: mr1
});
const layer2 = new ImageryLayer({
url: imageServiceURL,
mosaicRule: mr2
});
const map = new Map({
basemap: "hybrid",
});
const view1 = new MapView({
container: "viewDiv",
map: map,
center: {
x: 87.976322,
y: 24.04582,
spatialReference: 4326
},
zoom: 10,
popup: {
actions: []
},
});
minusRF = new RasterFunction();
minusRF.functionName = "Arithmetic";
minusRF.outputPixelType = "F32";
minusRF.functionArguments = {
"Raster" : layer1,
"Raster2" : layer2,
"Operation" : "2",
"ExtentType" : 0,
"CellsizeType" : 1}
const changeDetectionLayer = new ImageryLayer({
url: imageServiceURL,
id: "resultLayer",
);
changeDetectionLayer.renderingRule = minusRF
map.add(changeDetectionLayer);