Select to view content in your preferred language

Does Web Map support customized colorRamp distribution

1190
8
Jump to solution
03-01-2023 08:46 AM
GLIMichael
Emerging Contributor

We have a use case where we need to specify a customized distribution of the color ramps. Based on the documentation below, it seems like this is possible by specifying the name value pairs of "start" and "stop".

colorRamp object documentation: https://developers.arcgis.com/documentation/common-data-types/color-ramp-objects.htm

However, when I attempt to do this in a web map, the distribution does not change instead will still distribute evenly. I also noticed if you save the web map from the viewer, the "start"/"stop" key words will be dropped.

After some digging, I noticed that on the web map specification, the "start" "stop" keywords are not mentioned. Which makes me suspect maybe the "start" "stop" is not supported on web maps?

web map specification on colorRamp: https://developers.arcgis.com/web-map-specification/objects/colorRamp/ 

Can someone help me confirm whether the "start" "stop" keywords are supported on web maps?

Also there are two typos in the last json snippet of this page: https://developers.arcgis.com/documentation/common-data-types/color-ramp-objects.htm 

0 Kudos
1 Solution

Accepted Solutions
RussRoberts
Esri Notable Contributor

start/stop is for imagery layers but its not a part of the web map or web scene spec. This is why it will get removed when you save the map.  I'm not quite sure where the start/stop is stored where you reference - maybe in a layerfile? Under the web map though we don't reference the start/stop

https://developers.arcgis.com/web-map-specification/objects/colorRamp/

 

View solution in original post

8 Replies
RussRoberts
Esri Notable Contributor

You can set this in the spec but the properties depend on the layer you are using it for.

colorRamp above is for imagery layers

 

For another layer type like a Feature Layer you would define the stops under the visualvariables

https://developers.arcgis.com/web-map-specification/objects/colorInfo_visualVariable/

 

Publishing your own color ramps and customizing existing color ramps is something we are looking into but I dont have it assigned to a release yet. 

0 Kudos
GLIMichael
Emerging Contributor

Hi Russ,

Thanks for response.

We are using it for imagery layer.

We specified the start and stop in the JSON for the layer (through ArcGIS Python API), but the colors are still distributed evenly in the web map.

Furthermore, when I save the web map through the Web Map viewer then reload the JSON, the start/stop keys will be dropped from the JSON.

0 Kudos
RussRoberts
Esri Notable Contributor

There could be some unexpected JSON and that is why its getting removed on save causing the ramp to be altered. Does below look like what you are setting? 

 


layerDefinition": {
             "drawingInfo": {
                          "renderer": {
                                       "colorRamp": {
                                                    "colorRamps": [{
                                                                 "algorithm": "esriHSVAlgorithm",
                                                                              "fromColor": [
                                                                                           2,
                                                                                           34,
                                                                                           81,
                                                                                           255
                                                                                           ],
                                                                                 "toColor": [
                                                                                           7,
                                                                                           45,
                                                                                           95,
                                                                                           255
                                                                                   ],
                                                                                   "type": "algorithmic"
                                                                            },
                                                                            

0 Kudos
GLIMichael
Emerging Contributor

Hi Russ,

Yes, I can confirm that our JSON doesn't have unexpected components.

I slightly modified the sample you sent me to include the start, stop key words. The two colors should have a split of 10%-90%, but you will see in web map it's still 50/50 split.

Also try the save, then reload, and the start stop components will be dropped.

"layerDefinition": {
        "drawingInfo": {
            "renderer": {
                "type": "rasterStretch",
                "stretchType": "minMax",
                "colorRamp": {
                    "type": "multipart",
                    "colorRamps": [
                        {
                            "algorithm": "esriHSVAlgorithm",
                            "fromColor": [
                                2,
                                34,
                                81,
                                255
                            ],
                            "toColor": [
                                7,
                                45,
                                95,
                                255
                            ],
                            "type": "algorithmic",
                            "start": 0,
                            "stop": 10
                        },
                        {
                            "type": "algorithmic",
                            "algorithm": "esriHSVAlgorithm",
                            "fromColor": [
                                208,
                                208,
                                208,
                                100
                            ],
                            "toColor": [
                                225,
                                225,
                                225,
                                100
                            ],
                            "start": 10,
                            "stop": 100
                        }
                    ]
                },

 

0 Kudos
RussRoberts
Esri Notable Contributor

Yup that's the unexpected JSON for that styling we dont write that in for that set style on imagery. Would you be able to use classify and you set the max value for each stop

 

 

"colorRamp": {
							"type": "algorithmic",
							"algorithm": "esriHSVAlgorithm",
							"fromColor": [245, 245, 0, 255],
							"toColor": [255, 0, 0, 255]
						}
"type": "classBreaks",
					"classBreakInfos": [{
						"label": "-1.8 - 1.684",
						"classMaxValue": 1.684047,
						"symbol": {
							"type": "esriSFS",
							"color": [245, 245, 0, 255],
							"outline": {
								"type": "esriSLS",
								"color": [0, 0, 0, 255],
								"width": 0.75,
								"style": "esriSLSSolid"
							},
							"style": "esriSFSSolid"
						}
					}, {
						"label": "1.684 - 8.504",
						"classMaxValue": 8.503883,
						"symbol": {

 

0 Kudos
GLIMichael
Emerging Contributor

Unfortunately classify won't work for our use case, since we would like to see a smooth color transition within each value range. But it is good to know the start/stop cannot be used for imagery layer.

Our current workaround is to define evenly distributed colorRamps to mimic the customized color transition location.

A follow up questions, could you elaborate a bit on what layers support the start/stop keys? The keys are mentioned in this documentation, but seems like they are only for specific use cases?  https://developers.arcgis.com/documentation/common-data-types/color-ramp-objects.htm 

Thank you

0 Kudos
RussRoberts
Esri Notable Contributor

start/stop is for imagery layers but its not a part of the web map or web scene spec. This is why it will get removed when you save the map.  I'm not quite sure where the start/stop is stored where you reference - maybe in a layerfile? Under the web map though we don't reference the start/stop

https://developers.arcgis.com/web-map-specification/objects/colorRamp/

 

GLIMichael
Emerging Contributor

Thanks for the clarity and confirming that the start/stop are not used in web maps!

I added the start/stop in manually just to test it out.

I actually don't know where they can be used. Is there a sample use case or layer I can look at?

We had a customized color ramp used in Arc Pro that has uneven color distribution of 10%, 30%, 75%, 100%. We were trying to mimic the same color ramp in web map which prompted this discussion.

 

0 Kudos