0
votes

I have 100 polygons of different size. I want to color each polygon with different color. I have one of the attribute 'z-code' in polygon that starts from 1 to 100. Can I use this? or should I use any other attributes that I have for example name of polygon?

What is the best way to have different color in different polygons in Geo-Server? Any answer is appreciated.

1

1 Answers

0
votes

The easiest way to do this is to use a categorize function to map values from 1 - 100 to colours. So your SLD would look something like:

<PolygonSymbolizer>
   <Fill>
     <CssParameter name="fill">
       <ogc:Function name="Categorize">
         <!-- Value to transform -->
         <ogc:PropertyName>z-code</ogc:PropertyName>
         <!-- Output values and thresholds -->
         <ogc:Literal>#87CEEB</ogc:Literal>
         <ogc:Literal>0</ogc:Literal>
         <ogc:Literal>#FFFACD</ogc:Literal>
         <ogc:Literal>100</ogc:Literal>
         <ogc:Literal>#F08080</ogc:Literal>
       </ogc:Function>
     </CssParameter>
   </Fill>
</PolygonSymbolizer>