I am using geoserver to serve my shapefile data, and I use SLD as the style solution.

There are two fields in the data related to styling: type and status. The type field contains values like highway freeway parkway and etc. The status filed contains values like planning building completed.

Different arrangement of the type and status should result in different style, as shown in this table:

enter image description here

There are 9 rules for the style. Furthermore, the zoom level should be considered while styling, say I have 4 different rules related to the zoom level, there will be 9*4 = 36 rules finally.

Once there are new type values added, the number of rules will increase too.

I wonder how do you handle this kind of situation ?

  • 4
    You could do it with CSS (but read docs.geoserver.org/latest/en/user/styling/css/cascading.html) or generate it with some other offline tool.
    – BradHards
    Commented Apr 19, 2017 at 3:06
  • I second what BradHards says. The CSS extension is much easier than coding SLD by hand. It is not installed by default, so you need to download the extension first Commented Apr 19, 2017 at 7:38
  • 1
    CSS will give you a significant boost if the attributes are controlling independent properties, like, for example, if type controls color and status controls width, or something like that, as you can set them in independent rules and CSS will create the mixes for you. If instead each combination needs a unique, irregular styling, you'll have to create many rules, but it will still be less work to write. Commented Apr 19, 2017 at 8:28

1 Answer 1


The way SLD works, you'll need a bunch of filters like:

type=highway AND status=planning (This is pseudo code, you need to use the SLD Filter Expressions.)

As BradHards says, the CSS Styling Extension is a good way to make this easier.

If you only have to do it once, and you're happy to do it the long way, but more easily than hand-coding SLD, I use QGIS to set up my styles and then export to SLD. This gets you about 80% of the way there. You'll need to fix up any unhandled situations and maybe tweak things. Make sure you keep the QGIS styles simple!

  • 1
    I have tried qgis, but the sld generated by qgis can not be completely recognized by geoserver
    – giser
    Commented Apr 19, 2017 at 5:14
  • As I said, @giser, you can get 80% of the way there with QGIS. In terms of creating the big complex list you're after, I think you'll find it easier with QGIS than doing the SLD by hand! CSS is a very valid alternative, and may be better.
    – Alex Leith
    Commented Apr 19, 2017 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.