From: Andrea A. <aa...@op...> - 2009-01-22 08:44:03
|
Michael Bedward ha scritto: > Ah someone who understands SLD... it's dangerous admitting that Ajay - > people will ask you questions :-) > > I've seen examples of filling polygons in a small number of different > colours depending on the value of a data attribute. But do you know > if there is a way of specifying a colour ramp or category relationship > between the fill and an attribute's value in the SLD file ? There is no built-in way to do so, at least not for vector data, only the raster symbolizer has a ColorMap concept (which is in fact a way to declare a color ramp). Yet, not all hope is lost. The fill color can take pretty much any expression inside of it, so it can also take a filter function. Filter functions are pluggable, so you can write a custom one, register it in the GeoTools SPI (the plugin mechanism GeoTools and JAI use), and use it in your SLD. The result would look like: <CSSParameter name="fill"> <ogc:Function name="colorRamp"> <ogc:PropertyName>myAttribute</ogc:PropertyName> </ogc:Function> </CSSParameter> or maybe you can add all params to make a color ramp explicit, such as the array of colors and values. Maybe something like: <CSSParameter name="fill"> <ogc:Function name="colorRamp"> <ogc:Literal>#FF0000,#00FF00,...</ogc:Literal> <ogc:Literal>0,120,...</ogc:Literal> <ogc:PropertyName>myAttribute</ogc:PropertyName> </ogc:Function> </CSSParameter> That is, the first two arguments being two strings that you'll then parse into a list of colours and a list of values. Cheers Andrea -- Andrea Aime OpenGeo - http://opengeo.org Expert service straight from the developers. |