On Tue, Sep 13, 2011 at 1:09 PM, Mustafa646 <[email protected]> wrote:

> I have a shapefile with attribute named 'Type' and it has 45 distinct
> attribute values. I want to assign different colors to all these values. I
> have read Geoserver SLD document "attribute based polygon". I guess i need
> to write 40 rules for this. But I want some generic solution, may be by
> writing only one rule or something else. Is that possible ?
>
> Any generic solution for assigning different colors to all these 45
> distinct
> values ?
>

One option is to add a column to your data that contains the color
definition
as a hex string, and then use a single rule with:
<cssParameter
name="fill"><ogc:PropertyName>colorAttribute</ogc:PropertyName></cssParameter>

Another option is to use the recode function to get a more compact SLD:
http://geo-solutions.blogspot.com/2011/07/developer-corner-taming-massive-style.html

David in a previous thread discussed also about the idea of hashing the
feature
id, or some other attribute, into a color, so that the color of a polygon
does not change
as you pan and zoom around, but afaik this requires some coding in geotools.

Cheers
Andrea

-- 
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:      +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to