Using QGIS Layer Styles in GeoServer

GeoServer provides us with the functionality of styling our layers to match our preferences. However, many are the times that GeoServer users face problems while publishing their layers. Layer styles in GeoServer should be an easy task when doing web applications or publishing your GIS layers via GeoServer.

 
Today, I will focus on how to apply same styles for layers in GeoServer as in your QGIS project. Here are a few steps that can be followed to achieve the expected results.
Load a PostGIS layer in the map canvas in QGIS using the Add PostGIS layers option in Manage Layers toolbar.
 
The Add PostGIS tabledialog box appears and it gives the option to add a connection to our PostGIS tables
 
 
Add connection
 
Fill in the form with various parameters that correspond to the ones in the PostGIS database.
 
 
Click on connectto load layers in the public schema.
The layers should be loaded as shown below.
 
Choose the layer of choice and click Add to load the layer into canvas.
 

I will now style my Africa layer in categories based on the pop_dens_1 field.
Go to layer properties by double clicking on the layer in Layers section.
Select the Categorizedin Style section and choose pop_dens_1 as the column.
Leaving other settings default, click on classify and click Apply
 
Our Point
We want to use the style that we have applied to our layer in GeoServer or in our Published layer. This means that we need to save this style and use it in GeoServer. To do this, access the save style section in the layer properties window. Select SLD file (GeoServer supports SLD files).
 
 
Select the location to save the style.
We are done with QGIS for now.
 
Launch a browser and access GeoServer on your computer. E.g. http://localhost:8080/geoserver/web/
Access the stylessection on the left side of the page.
 
Go to Add a new style (We are adding the style that we saved from QGIS)
Access the stylessection on the left side of the page. Go to Add a new style (We are adding the style that we saved from QGIS)
 
Fill in the name and workspace that the style will be saved.
Then, at the bottom of the style page click on the Browse and choose the location of the SLD file that you saved from QGIS and click open .Click upload to load the style .
 
 Click on validate. If no validation errors click on submit and the style will be saved under layer styles.
On the publish section on layer in GeoServer choose africastyle  to apply it in our layer .
Access the layer preview  and click on OpenLayers against the Africa layer to load it.
 
The style on our layer should resemble that in our QGIS project.
We’ve just done styling in GeoServer in few minutes and everything is as we expected.
Repeat the process again to fully familiarize yourself with this process.
For inquiries leave a comment below……

Leave a Reply

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

Wanjohi Kibui

Passionate about harnessing the power of geospatial technology to create innovative solutions, I'm a GIS Consultant and Developer dedicated to building cutting-edge geospatial applications. With a keen eye for spatial analysis and a knack for problem-solving, I specialize in crafting solutions that seamlessly integrate technology and geography.

More Reading

Post navigation