I have a big set of GeoTIFF files being served by GeoServer. All the styles are previously generated and then posted through GeoServer REST API.

Then I need to send color and quantity parameters to those SLD files which I managed to accomplish using ENV request. So far so good.

The problem is now we will be getting specific user input for these parameters and the number of ColorMapEntry classes may vary.

For example:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0" xmlns:sld="http://www.opengis.net/sld">
      <sld:Name>Interpolated (IDW with NN search)</sld:Name>
            <sld:ColorMap type="ramp">
              <sld:ColorMapEntry quantity="${env('q0',0)}" label="0,0" color="${env('c0','#01ff05')}"/>
              <sld:ColorMapEntry quantity="${env('q1',0.2)}" label="0,2" color="${env('c1','#ffff0')}"/>
              <sld:ColorMapEntry quantity="${env('q2',0.5)}" label="0,5" color="${env('c2','#ff8400')}"/>
              <sld:ColorMapEntry quantity="${env('q3',2)}" label="2,0" color="${env('c3','#ff0000')}"/>

Here I can pass parameters via HTTP without any problems. But what if for this specific SLD file I have 6 ColorMapEntry classes? Is there a way I can tell GeoServer to dynamically generate these classes without having to previously parse a whole new SLD/XML file?

2 Answers 2


There is currently no way to do that in a fully dynamic way.

If you can program in Java, then have a look at the source code of the dynamic color map community module, it does not do what you want but it's somewhat close, you can use it as an inspiration to write a new rendering transformation taking a variable number of inputs (or two fixed inputs, the first one being a comma-separated list of numbers, and the second a comma-separated list of colors).

If you cannot develop but you know in advance that you won't have more than N colors, then create many styles, one taking 3 colors, one 4, and so on, and then have your client switch the style name in the GetMap.

If neither approach is suitable, you can also sponsor a developer to build this new functionality for you.

  • Tks Andrea. I think for now we don't have to go that deep biw, but I appreciate you provided with some important information. I'll give a try to your second suggestion
    – Pedro Cury
    Mar 8 at 13:11

Another possibility, you could send the SLD from the client to the server and have some code in the client that modifies a template with the required colorMap.

  • tks Ian. I'll give a look at this possibility too.
    – Pedro Cury
    Mar 8 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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