How to Apply Styled Layer Descriptor (SLD) in GeoServer

This tutorial will focus on outlining step by step process of applying a style on layer in GeoServer. A Style Layer Descriptor (SLD) file from QGIS will be used to style the layers.

Launch QGIS and Export the Styled Layer Descriptor.

Firstly, open QGIS and load the vector layer that you want to style. Apply the style of your choice on the layer then save the style as an SLD. To achieve that, proceed as follows:

Right click on the layer and select Properties.

The Layer properties window opens.

On the left panel, click on Symbology.

Navigate to the Layer Rendering section and click on the Style option. A dropdown menu appears. Select Save Style.

On the Save layer dropdown, select save style As SLD file then navigate to your project folder and save the style layer.

Launch GeoServer and Add the SLD to Styles.

Secondly, open GeoServer and import the SLD file which will be used to style the layer.

Navigate to http://localhost:8080/geoserver and log in using your username and password.

On the left panel, under the Data option, click on Styles. The Styles window appears.

Select the Add a new style option.

You will be prompted to enter the style name, select the workspace and the format of the style.

Under the Style Content section, upload the style file, which is the SLD file exported from QGIS.

Navigate to the SLD file and click upload. The XML formatting will populate on the text area then click the Validate button. An alternative method would be to open the SLD file using your code editor, copy the XML code and paste it on the GeoServer text area then click on Validate.

Click the Save button. The name of the newly created style will appear on the list of the other styles.

Next, Apply the Style to the Layer .

On the left panel, click on Layers. Navigate and click on the layer of interest.

Click on the Publishing tab and navigate to the WMS Settings. Change the Default style to the previously created SLD style.

Click Save.

Finally, Preview the Styled Layer.

Click on the Layer Preview option. Navigate to the Layer and click the OpenLayers option to preview the layer.

Previous Post
Next Post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.