[GIS] Dynamic SLD styling based on min / max value in a PostGIS column

cql-filtergeoserverpostgissld

I have a PostGIS table that contains the GDP of countries together with their polygon boundaries. I am using GeoServer to display this data via OpenLayers.

When styling the data, I want to avoid having to hardcode numeric range / colour pairs in my SLD file.

Is it possible to create an SLD style file that dynamically determines the minimum and maximum value of GDP that are present in a PostGIS column, for example through CQL, and then uses that information to colour the map?

Best Answer

Following Dynamic SLD styling - unique colours for linestrings I would suggest adding a "color value" column to your postGIS table is the easiest solution. The column should always be updated with respect to the current range of GDP values. Then, you might access it in your SLD with a PropertyValue in the CssParameter tag.