I have rasters that require a specific color per cell value. Here's a few of the scenarios
Scenario 1: I have a raster that represents true/false where cells are either 0 for true or 1 for false. In this case I can use the ColormapRenderer with 2 colors. This seems to correctly apply the color by assigning color index to value.
Scenario 2: I have a raster where cells have a non-linear int as its value. For example, cell values could be 1, 8, 22, 34 & 100. Lets say 1=red, 8=blue, 22=green, 34=black, & 100=white. There are no other cell values and there is never a no_data value in this sample. These numbers seem random, but they mean something to the analyst, so I cannot reduce them down to 0, 1, 2, 3, & 4 respectively. In this example, I tried using a ColormapRenderer with 5 colors, but only the cells with value 1 got a color and it would be my 2nd color in my list(again, based on index). I tried adding 101 colors to the renderer where I assign the correct color to index, i.e. colors[22] = green. I filled the rest of the colors list with Purple to make errors more visible. This resulted in most of the cells showing with their assigned colors, but there was a lot of purple mixed in. I do not know how to get this to work consistently with my data.
The ideal situation is a colormap with values similar to a unique value renderer. I just want to color my cells by value.
I was also looking into trying the Colormap RasterFunction ( Add raster data | ArcGIS Maps SDK for .NET | Esri Developer ), but I could not figure out the format for "color1" from the template shown below.
{
"raster_function":{"type":"Colormap_function"},
"raster_function_arguments":
{
"raster_colormap":{"colors":[color1,color2,...,colorN],"type":"Raster_function_variable"},
"raster":{"name":"raster","is_raster":true,"type":"Raster_function_variable"},
"type":"Raster_function_arguments"
},
"type":"Raster_function_template"
}
I've tried several different formats, but nothing seems to have any effect on the raster in my map. Here's the things I've tried:
1. RGB in an int array -> [200, 200, 200]
2. RGBA in an int array -> [200, 200, 200, 255]
3. Value + RGB -> [3, 200, 200, 200]
4. GPT recommended a structure like this:
"colors": [
{ "value": 0, "color": [0, 0, 0, 255] }, // Black
{ "value": 1, "color": [255, 0, 0, 255] }, // Red
{ "value": 2, "color": [0, 255, 0, 255] }, // Green
{ "value": 3, "color": [0, 0, 255, 255] } // Blue
]
The 3rd option using Value+RGB is what the RestAPI ( Raster function objects | ArcGIS REST APIs | Esri Developer ) shows in their samples, but I have never gotten any of the RestAPI raster functions to work in the Maps SDK, so I usually just use this for guidance/ideas rather than a 1:1. I have had success in the past with the structure from the "Add raster data" sample, so I assume this is the format that is expected.
I just do not know what it expects for [color1,color2,...,colorN]:
Any advice/tips/tricks would be greatly appreciated!
I'm having a similar issue and have not found a solution. I wish Remap RasterFunction would be supported, without it, I see no viable solution. For example I have some rasters that hold negative values and so there is no way to apply any colormap to it, or remap the values to positive.