- QGIS By Example
- Alexander Bruy Daria Svidzinska
- 774字
- 2025-02-22 02:47:18
Managing styles
As you can see from the previous section, developing styles is a time-consuming task. But the good thing is that once developed, styles are not lost. They can be saved, applied to other layers, and imported from and exported to external sources.
The main style management options are available from the Style button at the bottom row of the Style section under Properties as shown. The menu is pided into sections separated by horizontal lines. The first section is responsible for loading and saving styles. The second and third are for managing multiple styles for the layer, and at the bottom is the toggle for activating different styles (inactive and grayed out by default, when there's only one style available).

Tip
You can get access to some of these options by right-clicking on the layer's Styles contextual shortcut. For example, you can copy and paste a style from one layer to another, add a new style, or rename an existing style. Also, this is very convenient for rapid switching between multiple layer styles.
When you have finished polishing your style, it is wise to save it. There are three main options for doing this from the Style button of the Save Style menu:
- QGIS Layer Style File: The style is saved as a
.qml
file, which is a native QGIS format for storing styles. - SLD File: The style is exported to a style layer descriptor (
.sld
) file. This file type converts the original symbology into a single-symbol or rule-based type. This means categorized, graduated, heatmap, and other types of symbology may not be supported properly. Renderer-based symbology may not be supported properly. It may be convenient to save the symbology in an.sld
file if you plan to work on it within an external application, such as GeoServer. - Save in database: We use this option to store and distribute all our data and styles within a single SpatiaLite database. When loading a style, it is important to provide a meaningful name and an exhaustive description. This is very handy because if you want somebody else to work with your data and style it properly, they just need to connect to the database, load the spatial layers and styles, and apply them.
Once the style is saved, you can use Load from file (Style | Load Style | Load from file) or Load from database to select and apply the style.
Note
The QGIS community is very active in developing resources and eager to share them, so instead of spending a long time developing your own styles, you can apply ready styles provided by various users. We advise you to take a look at the following:
- Charley Glynn's OSM shapefile QGIS style sheets available at https://github.com/charleyglynn/OSM-Shapefile-QGIS-stylesheets
- 3liz styles for OpenStreetMap data in QGIS at https://github.com/3liz/osm-in-qgis
- Anita Graser's styles for SpatiaLite databases at https://github.com/anitagraser/QGIS-resources/tree/master/qgis2/osm_spatialite
- Ross McDonald's grayscale styles for OSM shapefiles in QGIS at https://github.com/mixedbredie/OSM-Shapefile-QGIS-stylesheets/tree/master/QML%20files/greyscale
You can download ready-to-use .qml
files from there and apply them to your layers, but it's important that attributes of your layers be the same as those used in the ready styles. Otherwise, you can use these styles as basic templates and adjust the field names and values manually.
Using several styles for the same layer
You can also get quick access to some styling properties from the layer's contextual Styles right-click shortcut, as shown here:

For example, you can easily copy a style from one layer and paste it to another. Moreover, you can apply several styles for one layer and switch between them when necessary. To add a one more style to the layer, follow these steps:
- Click on the right-click contextual shortcut of Add layer, which is under Styles.
- In the New style window, type the name for the new style, and click on OK, as shown in the following screenshot
- The layer's appearance will not be changed, because it relies on the last applied style for now. Open the layer's Properties dialog and adjust the new style like this:
- You can develop a new style in the Style section in a common way, as described earlier in the Developing your own styles section.
- Also, it's possible to upload a ready style by going to Style | Load Style.
- After the styling is done, click on the OK button. You will see that both the styles are available, either from the Style button menu or the Styles right-click contextual shortcut.
- You can develop as many styles as you wish, and use the toggle beside their names to switch between styles. Also, you can use the Add, Remove Current, and Rename Current shortcuts to manage multiple styles.