<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to apply Raster Function to an Image Service in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1144063#M76358</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have updated the code and attached the recent zipped file.&lt;/P&gt;&lt;P&gt;I am now able to chain the raster functions and display the image (attached below), though not entirely sure if the output is correct.&lt;/P&gt;&lt;P&gt;I would like to know if there is a way to display (render) the positive and negative change (that is, display the increase/decrease post the Minus arithmetic operation). Would using a custom raster function be a good idea? Is it possible to do so?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_0-1644937229898.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33933iD2C8A35CCB30845C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_0-1644937229898.png" alt="MariamJamilah_0-1644937229898.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Feb 2022 15:04:02 GMT</pubDate>
    <dc:creator>MariamJamilah</dc:creator>
    <dc:date>2022-02-15T15:04:02Z</dc:date>
    <item>
      <title>How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143581#M76329</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also like to do change detection using the same two slices, please suggest how to go about it?&lt;/P&gt;&lt;P&gt;I have provided the code that I am currently using to do the above but the result is incorrect, please help!&lt;/P&gt;&lt;P&gt;I am using ArcGIS JS API 4.22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  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) =&amp;gt; {

        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);  
        
        &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 16:27:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143581#M76329</guid>
      <dc:creator>MariamJamilah</dc:creator>
      <dc:date>2022-02-14T16:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143663#M76331</link>
      <description>&lt;P&gt;For the "Raster" and "Raster2" parameters, use the raster ids.&amp;nbsp; For example, if "Reclass_IntYear2015" has an object id of 5 then the "Raster" parameter should be "$5".&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/documentation/common-data-types/raster-function-objects.htm" target="_blank"&gt;https://developers.arcgis.com/documentation/common-data-types/raster-function-objects.htm&lt;/A&gt;&lt;BR /&gt;- Check out the section "Using rasters in rendering rules"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 16:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143663#M76331</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2022-02-14T16:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143672#M76332</link>
      <description>&lt;P&gt;Thank you for your response!&lt;/P&gt;&lt;P&gt;I am still unable to understand how to display the output of the raster function. The output is dynamic and must be generated on the fly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 16:40:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143672#M76332</guid>
      <dc:creator>MariamJamilah</dc:creator>
      <dc:date>2022-02-14T16:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143703#M76334</link>
      <description>&lt;P&gt;I have the same question. Any sample code for this?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:11:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143703#M76334</guid>
      <dc:creator>KrishV</dc:creator>
      <dc:date>2022-02-14T17:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143908#M76345</link>
      <description>&lt;P&gt;Do you have a CodePen showing the issue, or a URL to the image service?&amp;nbsp; The link to the help topic provided above shows how to use the raster object id as input parameter to the raster function.&amp;nbsp; If you're building some type of UI to pick the years then you'll need to know the available raster ids and how they corresponds to each year.&amp;nbsp; Temporal information can be modeled in many different ways, but in your code above it seems to be part of a raster attribute so you can get those values via a query into the service.&amp;nbsp; Additionally, you might need to chain together other Raster Functions to provide appropriate colors based on the the type of data or desired visualization, or maybe use an appropriate renderer.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const changeDetectionLayer = new ImageryLayer({
  url: imageServiceURL,
  renderingRule: {
    functionName": "Arithmetic",
    functionArguments: {
      "Raster" : "$5",
      "Raster2" : "$6",
      "Operation" : "2",
      "ExtentType" : 0,
      "CellsizeType" : 1
    },
    outputPixelType: "f32"
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 01:36:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143908#M76345</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2022-02-15T01:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143938#M76347</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Yes,&amp;nbsp; I will be using a UI to pick the years. The image service has a limited number of rasters and therefore I can pick the objectId for each corresponding year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The major issue that I am facing is with displaying the output of the raster function. I am still unsure if using a renderingRule is the way to go about it. I have used the snippet that you have provided and I get a black image as output. I have attached the image and code (zipped file) for your reference.&lt;/P&gt;&lt;P&gt;As suggested, if I have to chain the raster functions as follows: arithmetic --&amp;gt; remap --&amp;gt; colormap. How do I use output of previous raster function in the following function and how do I finally display the result image?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for helping me out!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_0-1644899021057.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33915i4E4265CD0DA99FF2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_0-1644899021057.png" alt="MariamJamilah_0-1644899021057.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 04:31:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1143938#M76347</guid>
      <dc:creator>MariamJamilah</dc:creator>
      <dc:date>2022-02-15T04:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1144063#M76358</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have updated the code and attached the recent zipped file.&lt;/P&gt;&lt;P&gt;I am now able to chain the raster functions and display the image (attached below), though not entirely sure if the output is correct.&lt;/P&gt;&lt;P&gt;I would like to know if there is a way to display (render) the positive and negative change (that is, display the increase/decrease post the Minus arithmetic operation). Would using a custom raster function be a good idea? Is it possible to do so?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MariamJamilah_0-1644937229898.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33933iD2C8A35CCB30845C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MariamJamilah_0-1644937229898.png" alt="MariamJamilah_0-1644937229898.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 15:04:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1144063#M76358</guid>
      <dc:creator>MariamJamilah</dc:creator>
      <dc:date>2022-02-15T15:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply Raster Function to an Image Service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1144090#M76360</link>
      <description>&lt;P&gt;Glad to hear you got it working.&amp;nbsp; There are many ways to model and display the 'difference' between two rasters; two common types I use are relative and absolute.&amp;nbsp; Displaying relative values show how much gain or loss is associated with each pixel. Displaying absolute difference will translate the results into three values: gain, loss, and no change. Depending on the source data and desired results you might want to add a Remap RF that narrows down the results into a well known set of values, then you could more easily match these values via a ColorMap RF.&amp;nbsp; I hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 15:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-apply-raster-function-to-an-image-service/m-p/1144090#M76360</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2022-02-15T15:40:35Z</dc:date>
    </item>
  </channel>
</rss>

