I have a dynamic style in Geoserver, like below:

      <sld:ColorMapEntry color="#2c7bb6" quantity="${env('low',0)}" label="${env('low',0)}"/>
      <sld:ColorMapEntry color="#64a5cd" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 1 / 9}"/>
      <sld:ColorMapEntry color="#9dcfe4" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 2 / 9}"/>
      <sld:ColorMapEntry color="#c7e6db" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 3 / 9}"/>
      <sld:ColorMapEntry color="#edf7c9" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 4 / 9}"/>
      <sld:ColorMapEntry color="#ffedaa" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 5 / 9}"/>
      <sld:ColorMapEntry color="#fec980" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 6 / 9}"/>
      <sld:ColorMapEntry color="#f99e59" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 7 / 9}"/>
      <sld:ColorMapEntry color="#e85b3a" quantity="${env('low',0) + (env('high',0) - env('low',0)) * 8 / 9}"/>
      <sld:ColorMapEntry color="#d7191c" quantity="${env('high',0)}" label="${env('high',0)}"/>      

An example request:


I was expecting labels to take the values provided with the enviroment variables passed in the GetLegendGraphics request, as it's working with the quantity parameter for GetMap requests.

The output image i'm getting:

enter image description here

It seems that whatever you pass in the label parameter is treated as string, and dynamic values are not working with the syntax used.

So it's possible and I'm using the wrong syntax? Or it's not possible to make the label dynamic?

Also, Geoserver says my style is not valid and get some errors during the validation, but the style is working:

line 18: cvc-attribute.3: The value '${env('low',0) + (env('high',0) - env('low',0)) * 7 / 9}' of attribute 'quantity' on element 'sld:ColorMapEntry' is not valid with respect to its type, 'double'.

1 Answer 1


The documentation does not include "label" as an attribute that can take expressions, it states "Most of the ColorMapEntry attributes (color, quantity and opacity) can be defined using cql expressions". So only color, quantity and opacity can use expressions, see also:


Not all is lost though, if you want you push for "label" to also support expressions, see the expected process here:


  • Ok Thank you very much, I'll request this feature as soon as possible. By the way you saved me hours of finding if it was possible. Don't you think it would be nice if that exist? Jan 11, 2018 at 11:40
  • 1
    I have never needed it, but sure, would'nt hurt to have it :) Jan 11, 2018 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.