Using server-side renderer for image service

683
2
Jump to solution
04-26-2019 06:36 PM
ShannonDeArmond
New Contributor III

I have a Living Atlas layer shared on my portal (not accessible outside my intranet sadly). The layer includes some pre-built raster functions. What I'm trying to do is load the layer into a webmap using the 3.28 ArcGIS JS API and apply a specific raster function to affect the appearance.

Screen shot of raster functions descriptions from rest page

Based on my reading here and here, it seems like this should be possible. The layer loads just fine but the raster function is not being applied. It's coming in as the default grey-scale stretch symbology and with no helpful errors in the console to help me along. Can anyone point me in the right direction?

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Raster Function Test</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.28/esri/css/esri.css">

    <style>
      html,
      body,
      #mapDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>

    <script src="https://js.arcgis.com/3.28/"></script>
    <script>
      require([
	      'esri/map',
        'esri/layers/ArcGISImageServiceLayer',
        'esri/layers/ImageServiceParameters',
        'esri/layers/RasterFunction',
        'dojo/domReady!'
      ],
        function(
          Map,
          ArcGISImageServiceLayer,
          ImageServiceParameters,
          RasterFunction
        ) {

        var map = new Map("mapDiv", {
          basemap: "topo",
          center: [-122.45, 37.75],
          zoom: 13,
        });

        var serviceRFT = new RasterFunction({
          functionName: "Slope_Degrees_Map",
          variableName: "Raster"
        });

        var params = new ImageServiceParameters();
        params.noData = 0;
        var slopeImageLyr = new ArcGISImageServiceLayer("https://data.farwestern.com/portal/sharing/servers/a1ba14d09df14f42ad6ca3c4bcebf3b4/rest/services/WorldElevation/Terrain/ImageServer", {

          visible: true,
          id: 'la_slope',
          opacity: 0.7,
          renderingRule: serviceRFT,
          imageServiceParameters: params
        });

        map.addLayer(slopeImageLyr);

    });
  </script>
</head>

<body>
  <div id="mapDiv"></div>
</body>
</html>
0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

Set the renderingRule on imageServiceParameters in the layer constructor. So in your code, move the rendering rules to imageServiceParameters. The reason is that renderingRule is not an option for the image layer constructor but imageServiceParameters is.

Hope this makes sense,

-Undral 

View solution in original post

2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Set the renderingRule on imageServiceParameters in the layer constructor. So in your code, move the rendering rules to imageServiceParameters. The reason is that renderingRule is not an option for the image layer constructor but imageServiceParameters is.

Hope this makes sense,

-Undral 

ShannonDeArmond
New Contributor III

Thank you for your help, Undral! That did the trick.

0 Kudos