Skip to content

Publishing a Style

In GeoServer, styles determine how your data will be visually represented on the map. By defining a style and linking it to a layer, you control the colors, line widths, fill patterns, and other visual elements that make your data both clear and visually appealing. This step is essential for presenting information in a way that’s easy to interpret and matches your project’s design requirements.


Step 1: Access Creation Page

Before you can create a style, you’ll first need to open the style creation interface in GeoServer.

  1. In the left-hand menu, under the Data section, click Styles.

  2. Click Add New Style.

  3. The New Layer Group page will open.


📝
Styles can be global, which means they can be defined once and applied to layers across different workspaces.


Style Page
Image credit: GeoServer


Step 2: Create Style

Now that you’ve accessed the style creation interface, it’s time to define the basic properties and generate an initial style that you can later refine.

  1. On the New Style page, enter the following details:

    Field Value
    Name background
    Workspace manual
    Format SLD


  2. Under Generate a default style, select Line.

  3. Click Generate... to automatically populate the style editor with a basic line style outline.

  4. Press Apply to save the style. Once saved, additional interactive editing options will become available.


📝
You can also upload an already-created SLD file if you have one prepared.


Create Style
Image credit: GeoServer


Step 3: Edit Style

With your base style created, you can now make adjustments to refine the layer’s appearance.

  1. Go to the Publishing tab at the top of the page.

  2. Enable the Default checkbox next to ne_110m_coastline.

  3. Open the Layer Preview tab from the top of the page.

  4. Modify the style by changing the stroke color to blue (#004eff) and adjusting the stroke-width.


    <?xml version="1.0" encoding="ISO-8859-1"?>
    <StyledLayerDescriptor version="1.0.0"
      xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
      xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
      xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
      <NamedLayer>
        <Name>background</Name>
        <UserStyle>
          <Title>Background</Title>
          <FeatureTypeStyle>
            <Rule>
              <Title>Background</Title>
              <PolygonSymbolizer>
                <Stroke>
                  <CssParameter name="stroke">#004eff</CssParameter>
                  <CssParameter name="stroke-width">0.25</CssParameter>
                </Stroke>
              </PolygonSymbolizer>
            </Rule>
          </FeatureTypeStyle>
        </UserStyle>
      </NamedLayer>
    </StyledLayerDescriptor>
    


  5. Click Apply to update the style and preview the changes in real time.

  6. When satisfied with the result, click Save to finalize your edits.


Edit Style
Image credit: GeoServer