<?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: Use pre-defined color ramps with Raster (Stretch Renderer) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1601394#M86791</link>
    <description>&lt;P&gt;Okay, thanks to the hints from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;I was able to piece this together.&lt;/P&gt;&lt;P&gt;The sample referred to is this one: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-renderer/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-renderer/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There was also an important distinction between the regular (symbology) color ramps module and the raster color ramps module.&lt;/P&gt;&lt;P&gt;Here's the relevant code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import Color from "@arcgis/core/Color.js";
import * as rasterColorRamps from "@arcgis/core/smartMapping/raster/support/colorRamps.js";
import RasterStretchRenderer from "@arcgis/core/renderers/RasterStretchRenderer.js";

let colors = rasterColorRamps.byName("Blue and Brown 1")?.colors;
// colors could be undefined/null (if name doesn't exist)
// so we need to protect against that with a default
if (!colors){
  colors = [new Color("#6b2600ff"), new Color("#b59273ff"), new Color("#fffee6ff"),
            new Color("#809298ff"), new Color("#002649ff")];
}
const colorRamp = rasterColorRamps.createColorRamp({colors: colors});
const renderer = new RasterStretchRenderer({
  colorRamp: colorRamp,
  stretchType: "min-max",
  dynamicRangeAdjustment: true,
});&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 01 Apr 2025 17:12:52 GMT</pubDate>
    <dc:creator>BillMitchell</dc:creator>
    <dc:date>2025-04-01T17:12:52Z</dc:date>
    <item>
      <title>Use pre-defined color ramps with Raster (Stretch Renderer)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1600881#M86780</link>
      <description>&lt;P&gt;I have some cloud-optimized geotiffs (COGs) with elevation data that I'd like to display using the pre-defined color ramps (for instance, "Blue and Brown 1") and using custom min/max values set by the user.&lt;/P&gt;&lt;P&gt;Unfortunately, this type of functionality seems to be completely undocumented---or, where it is documented, the documentation no longer applies.&amp;nbsp; I was able to find &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-change-the-colors-on-a/td-p/23588" target="_self"&gt;a forum post where they did roughly what I want to do&lt;/A&gt;, but that no longer works with the Javascript API v4.32.&lt;/P&gt;&lt;P&gt;In my mind, this should be a relatively simple task:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const renderer = new RasterStretchRenderer({
  colorRampName: "Blue and Brown 1",
  type: "min-max",
  min: 123,
  max: 456,
  layer: myLayer
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what's the obvious solution that I'm missing, which isn't pointed out in the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-imagerytilelayer/" target="_self"&gt;ImageryTileLayer documentation&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 15:28:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1600881#M86780</guid>
      <dc:creator>BillMitchell</dc:creator>
      <dc:date>2025-03-31T15:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use pre-defined color ramps with Raster (Stretch Renderer)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1600938#M86782</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/427502"&gt;@BillMitchell&lt;/a&gt;,&amp;nbsp;thanks for posting your question here. In the post you referenced, the solution was to use a specific renderer, the RasterStretchRenderer.&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-RasterStretchRenderer.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-RasterStretchRenderer.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;In your code, you create a new renderer with an unsupported type:&lt;/P&gt;&lt;PRE&gt;type: "min-max"&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;These are the supported renderer type values:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#type" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#type&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And here is the renderer doc for the layers of interest:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#renderer" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#renderer&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#renderer" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#renderer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:40:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1600938#M86782</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2025-03-31T16:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Use pre-defined color ramps with Raster (Stretch Renderer)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1600982#M86783</link>
      <description>&lt;P&gt;Sorry, I was coming up with the properties via pseudo-code.&amp;nbsp; By 'type' I meant 'stretchType', for which "min-max" is an accepted value (&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-RasterStretchRenderer.html#stretchType" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-RasterStretchRenderer.html#stretchType&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 18:01:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1600982#M86783</guid>
      <dc:creator>BillMitchell</dc:creator>
      <dc:date>2025-03-31T18:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Use pre-defined color ramps with Raster (Stretch Renderer)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1601314#M86789</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you are asking how to set colorRamp on RasterStretchRenderer. Correct me if I am wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may find convenience methods found in &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-raster-support-colorRamps.html#methods-summary" target="_self"&gt;colorRamps&lt;/A&gt; module. For example &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-raster-support-colorRamps.html#byName" target="_self"&gt;byName()&lt;/A&gt; method returns predefined color ramp based on the one of the system color ramps. You can get the names of predefined color ramps by calling &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-raster-support-colorRamps.html#names" target="_self"&gt;names&lt;/A&gt; method. &lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-imagery-renderer" target="_self"&gt;This sample&lt;/A&gt; takes advantage of colorRamps module and you can use the same technique to create the colorRamps for the RasterStretchRenderer as shown below.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function changeColorRamp(name) {
  const colors = colorRamps.byName(name);
  return colorRamps.createColorRamp(colors);
}

let colorRamp = changeColorRamp("Elevation #1");

// set the shaded relief renderer parameters
const renderer = new RasterShadedReliefRenderer({
  altitude: 45,
  azimuth: 315,
  hillshadeType,
  zFactor: 1,
  scalingType: "adjusted",
  colorRamp
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I definitely agree that the documentation could be better.&amp;nbsp; We will add a link to colorRamps module in RasterStretchRenderer.colorRamp description and add a code snippet.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 15:24:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1601314#M86789</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2025-04-01T15:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Use pre-defined color ramps with Raster (Stretch Renderer)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1601394#M86791</link>
      <description>&lt;P&gt;Okay, thanks to the hints from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;I was able to piece this together.&lt;/P&gt;&lt;P&gt;The sample referred to is this one: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-renderer/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-renderer/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There was also an important distinction between the regular (symbology) color ramps module and the raster color ramps module.&lt;/P&gt;&lt;P&gt;Here's the relevant code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import Color from "@arcgis/core/Color.js";
import * as rasterColorRamps from "@arcgis/core/smartMapping/raster/support/colorRamps.js";
import RasterStretchRenderer from "@arcgis/core/renderers/RasterStretchRenderer.js";

let colors = rasterColorRamps.byName("Blue and Brown 1")?.colors;
// colors could be undefined/null (if name doesn't exist)
// so we need to protect against that with a default
if (!colors){
  colors = [new Color("#6b2600ff"), new Color("#b59273ff"), new Color("#fffee6ff"),
            new Color("#809298ff"), new Color("#002649ff")];
}
const colorRamp = rasterColorRamps.createColorRamp({colors: colors});
const renderer = new RasterStretchRenderer({
  colorRamp: colorRamp,
  stretchType: "min-max",
  dynamicRangeAdjustment: true,
});&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Apr 2025 17:12:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-pre-defined-color-ramps-with-raster-stretch/m-p/1601394#M86791</guid>
      <dc:creator>BillMitchell</dc:creator>
      <dc:date>2025-04-01T17:12:52Z</dc:date>
    </item>
  </channel>
</rss>

