I have a "geometry" and a "rating" column. I want to symbolize the geometries in an SLD (PolygonSymbolizer) but fill it with a color value that is interpolated between BLUE-PURPLE-RED based on the rating value, in range -100 to +100.

So the polygon would have a single fill color, but the color should be dynamic, based on the value.

I tried superimposing two symbolizers with scaled alpha values for the fill color: -100 to 0.0, +100 to 1.0 for red and the negated value for blue, but that doesn't work correctly because I get different results depending on whether I do red first and then blue or the other way around.


  • 1
    I could just add 21 rules for every decile (and 0) but that seems like an awful lot of work! Nov 16, 2014 at 10:43
  • Since my layer is based on a view, I "solved" it by adding this column: color2hex(cast(round((rating / 200.0 + 0.5) * 255) * 65536 + round((rating / -200.0 + 0.5) * 255) as integer)) as color With a custom SQL function. Hardly a "clean" solution though. Nov 16, 2014 at 10:50

1 Answer 1


When searching for a solution for "colour gradient based SLD for polygons" I found this page: http://docs.geoserver.org/stable/en/user/styling/sld/tipstricks/transformation-func.html

Excerpt: "Interpolate transforms a continuous-valued attribute into another continuous range of values."

GeoServer provides a solution, but it is not called something with "gradient".

I hope this helps.

  • Thank you! The "interpolate" function is exactly what I was looking for. Jun 9, 2020 at 3:18

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.