Introduction to the OpenGeo Suite

Styling Layers in GeoServer

GeoServer can render geospatial data as images and return them for viewing in a browser. This is the heart of the Web Map Server (WMS). However, geospatial data has no inherent instructions for visualization, therefore additional information, in the form of a style, needs to be applied to data for it to be displayed a certain way.

GeoServer uses the Styled Layer Descriptor (SLD) markup language to describe geospatial data.

In this section, we will:

  1. Load an SLD file for (most of) our layers,
  2. Have a quick look at the syntax of SLD, and
  3. Apply those styles to our layers.

Loading Styles

  1. From the GeoServer menu, click on the Styles link,

  2. The list of all styles currently defined in GeoServer opens.

  3. Find the earth_cities style in your list. Click the entry to open the SLD Style Editor.

  4. Two properties should be pretty evident here:

    • The Name of the style,
    • What/where the SLD is.
  5. Have a look at the layout of the SLD. What do we notice?

    • It looks like XML
    • There are a few standard tags/attributes
    • Some specific symbology instructions happen in the middle
    • It’s not terse
  6. This is a very basic SLD that universally renders a square in dark yellow. We could start editing the SLD by hand to change some of this around, but there’s an easier way to see differences in visualization. At the bottom of this page, click the Choose File button and locate the file <workshop>\styles\cities.sld. Select it and click Open.



    Don’t jump to the Submit button yet. Patience.

  7. Now click the Upload ... link.

  8. The contents of the SLD editor, are replaced by the contents of the SLD file which contains “far more elegant” styling instructions than the default.

  9. It’s a good idea to click the Validate button to ensure that the code doesn’t contain any errors.

  10. Click the Submit button to save the uploaded SLD into the current style definition.



    The updated definition is saved as an SLD file on your local machine in <user>\.opengeo\data_dir\styles\.

  11. Repeat this process for both the earth_countries and earth_ocean styles. The source SLDs should be in your <workshop>\styles\ directory.

  12. Preview one/all/some of the layers. How do they look now?


Now you’ve got style!

Continue Reading

Previous: Other supported data formats

Next: Creating a layer group

This Page

About Boundless

Boundless provides commercial open source software for internet mapping and geospatial application development. We are dedicated to the growth and support of open source software.


This work is licensed under a Creative Non Commercial-Commons Attribution-Share Alike 3.0 United States License. Feel free to use this material, but we ask that you please retain the Boundless branding, logos and style.

Creative Commons License