Legend Item Label when using Colormap Raster Function

2180
1
Jump to solution
01-16-2017 09:26 AM
JoanneMcGraw
Occasional Contributor III

Using the ESRI JSAPI 3.18 and ArcGIS Server 10.4.1, I have an image service of crops that I have applied a Colormap Raster Function to. It displays only a single value from the raster, 122 which stands for "Pasture and Forages". Is there any way I can define this Colormap so that it will indicate to the Legend dijit that the text that should be displayed for that Colormap definition is "Pasture and Forages"?

I am attaching an HTML example page of what I am seeing as it is working for me now. This HTML will display the image and it's legend with the Colormap Raster Function applied. If you'd like to view the data without the Colormap, simply comment out the setRenderingRule line.

Is this even possible?

Cheers,

jtm

0 Kudos
1 Solution

Accepted Solutions
JoanneMcGraw
Occasional Contributor III

I finally contacted ESRI Support about this and received the following reply:

I've received an update from Redlands and they confirmed the limitation that an image service's legend cannot be modified, that using a rendering rule will cause the pixels to be labeled by the pixel value instead of other values.

From the Javascript side, the Widget doesn't allow you to change the legend label. The LayerList with legend Widget is available on Github, I believe this is an option in case you want to create a Widget and customize the Legend label.

Link : https://github.com/Esri/arcgis-dijit-layer-list

Esri inc. can log an enhancement request for you if you like and In order to log it, Esri inc. need to know details about your use case.  The sample you sent illustrates the problem, but how are you going to actually use the image service?   Are you building one or more applications that will only display some of the crops in the image service?  The more detail I have for that, the better I can explain your need for this capability  to the developers.

I responded with the following excerpt, which includes the workaround we'll be employing:

This is actually an example of something we are doing in two different of applications where we have a number of images depicting different years of data (one app focuses on specific crops and the other on land use). Users are interested in highlighting certain values to the exclusion of all else because these types of images can be visually complicated making it difficult for the human eye to discern areas of concentration of  a particular crop or land use. For example, would you know, looking at  http://www.arcgis.com/home/webmap/viewer.html?url=http://www.agr.gc.ca/atlas/rest/services/imageserv...  as it is displayed, that there are three specific areas where “Corn” is grown nationally and where those concentrations are?  

 

And, while we “could” prepare renderers to attach to the services in question, doing so limits what the user can choose to look at. For example, they may be interested in all Cereals, not just Corn; or perhaps, Corn and Soybeans...the possibilities are endless.

 

Now, whether ESRI determines that this is something that should be done is up to them. Personally, I think it should be optional to define an associated label in the colormap item definition and have that picked up by the Legend dijit but I’m sure they’ll figure out what works best for them and their users.

 

Extending/maintaining a custom widget is not feasible because we’d need to revisit it every time there was an upgrade to the JSAPI to ensure there’s nothing in the new functionality we need/want and will therefore have to port our code and customize it again, ad infinitum. Instead, what we’ll do, is create an empty polygon layer and define the symbology we use in the images and simply add that to the map. We can then use the Legend’s layerInfos array to include that layer and not the images, so the entire Legend for all the crops or land uses will be displayed at all times. Not optimal, but certainly better than a pixel value.

View solution in original post

0 Kudos
1 Reply
JoanneMcGraw
Occasional Contributor III

I finally contacted ESRI Support about this and received the following reply:

I've received an update from Redlands and they confirmed the limitation that an image service's legend cannot be modified, that using a rendering rule will cause the pixels to be labeled by the pixel value instead of other values.

From the Javascript side, the Widget doesn't allow you to change the legend label. The LayerList with legend Widget is available on Github, I believe this is an option in case you want to create a Widget and customize the Legend label.

Link : https://github.com/Esri/arcgis-dijit-layer-list

Esri inc. can log an enhancement request for you if you like and In order to log it, Esri inc. need to know details about your use case.  The sample you sent illustrates the problem, but how are you going to actually use the image service?   Are you building one or more applications that will only display some of the crops in the image service?  The more detail I have for that, the better I can explain your need for this capability  to the developers.

I responded with the following excerpt, which includes the workaround we'll be employing:

This is actually an example of something we are doing in two different of applications where we have a number of images depicting different years of data (one app focuses on specific crops and the other on land use). Users are interested in highlighting certain values to the exclusion of all else because these types of images can be visually complicated making it difficult for the human eye to discern areas of concentration of  a particular crop or land use. For example, would you know, looking at  http://www.arcgis.com/home/webmap/viewer.html?url=http://www.agr.gc.ca/atlas/rest/services/imageserv...  as it is displayed, that there are three specific areas where “Corn” is grown nationally and where those concentrations are?  

 

And, while we “could” prepare renderers to attach to the services in question, doing so limits what the user can choose to look at. For example, they may be interested in all Cereals, not just Corn; or perhaps, Corn and Soybeans...the possibilities are endless.

 

Now, whether ESRI determines that this is something that should be done is up to them. Personally, I think it should be optional to define an associated label in the colormap item definition and have that picked up by the Legend dijit but I’m sure they’ll figure out what works best for them and their users.

 

Extending/maintaining a custom widget is not feasible because we’d need to revisit it every time there was an upgrade to the JSAPI to ensure there’s nothing in the new functionality we need/want and will therefore have to port our code and customize it again, ad infinitum. Instead, what we’ll do, is create an empty polygon layer and define the symbology we use in the images and simply add that to the map. We can then use the Legend’s layerInfos array to include that layer and not the images, so the entire Legend for all the crops or land uses will be displayed at all times. Not optimal, but certainly better than a pixel value.

0 Kudos