[GIS] GeoServer SLD: fill a polygon with color sampled from gradient

colorgeoserverpolygonsld

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.

http://i.imgur.com/P8cmV5X.png

Best Answer

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.