geoserver

How to apply SLD in GeoServer

This tutorial will focus on outlining step by step process of applying a style on a 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.

Layer in QGIS - GeoServer

The Layer Properties window opens.

On the left panel, click on Symbology.

Style Dialog QGIS - GeoServer

Navigate to the Layer Rendering section and click on the Style option. A drop down 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.

Saving a Style - GeoServer

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.

Styles List in GeoServer

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.

New Style in GeoServer

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.

Style Content in GeoServer

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.

Styled Layer GeoServer

Leave a Reply

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

Risper Mutinda

Hello. I am Risper Mutinda. I am a passionate Web and GIS Developer but more importantly, I am passionate about Technology.

More Reading

Post navigation