4.4. Exporting and Importing Styles#
The layers in QGIS are saved separately from the settings and styles of a QGIS Project. This means that if you load the same layers into a different QGIS project, the symbology and styling of the data will be different. QGIS lets you save the symbology and styling of a layer as a separate file (.qml-files). Working with .qml-files saves you a lot of work and assures consistency between your maps.
A .qml-file saves the information of a particular layer. This includes the colours, outlines, shapes, labelling, as well as the Layer configuration, attribute table settings, and other options you have set for a layer in your QGIS project that are not related to the data files themselves. You can choose whether to save only the colour symbology or any additional information.
You can export a style into the same folder as the data so your colleagues can apply the same styling when loading the data into QGIS. Some organisations may also use standardised symbols or colours in their maps.
For example, if you want to send a layer to your colleague with the same styling as you, it is best to check the “Layer properties”, “Symbology”, and “Labels” categories (and any additional styling options you have set). If you only wish to save a certain colouring, line thickness, or labeling style, you only need to check the respective boxes.
4.4.1. Saving or exporting styling settings#
Open the styling panel and click on
Styles. A dropdown menu will open with the option to export the layer styling.Since in this case, the styling is for exactly that dataset, you can leave all the boxes checked.
Select a location and name for the styling. The styling will be saved as a
.qmlfile. Make sure it is saved in the same folder as the dataset and give it the same name as the corresponding dataset. This way, when loading the data into QGIS, the styling will automatically be applied.
Fig. 4.40 Save Layer styling window in QGIS 30.30.2.#
When working with similar data (e.g. building types or flooding risk), it is useful to have template styles that can be quickly loaded into your QGIS-project or saved in your Styling Template library.
Tip
When a styling is saved in the same location as the data and has the same name as the corresponding dataset, the styling will be automatically applied to the layer when loading the data into QGIS!
4.4.2. Loading a style into a QGIS-project#
Open the style manager:
Settings>Style managerClick on
import/exportand selectimport itemsNavigate to the folder where the style is saved and click import.
The style should now be available as a preset in the styling panel.
Note
You can also import styles directly in the styling panel of a layer. But it will not be added to your style library unless you save it into your library.
Tip
You can copy styles from one layer to another:
Right-click on the styled layer →
Styles→Copy Style→All Style Categories.Right-click on the second layer →
Styles→Paste Style→All Style Categories.
4.4.3. Self-Assessment Questions#
Test your knowledge
What are the advantages of creating and using styles?
Answer
Consistency: ensures uniform symbology across maps and projects
Reusability: you can apply the same style to different layers or across projects without re-building from scratch.
Efficiency: saves time when styling many layers (by just loading the style file).
Shareabilty: you can share your visual designs (symbols, colour ramps, label settings) with colleagues.
How do you import or export a style?
Answer
In QGIS, right-click on the layer →
Properties→SymbologyIn the bottom left corner, there is a dropdown menu called
Stylewith options to import or export styles.
How would you share styles with colleagues or across different machines? What should you watch out for (e.g. file paths, resource dependencies)?
Answer
Open the
Symbologytab in thePropertieswindow.In the bottom left corner, click on
Style→Save Style.Specify the name and saving location.
In the file browser, find the
.qml-file and share it with your colleague.
Things to watch out for:
File paths/references: If the style references external files (SVGs, images) with absolute paths, those paths may break on another machine.
Missing resources: If an external resource (symbol, image) is absent or moved, the style may fail or fall back to default symbols.
Version compatibility: Styles created in one version of QGIS may not fully work or may degrade in another version
Data compability: If you have set rules or classification based on a layer’s attributes, the column names and attributes must be present in the dataset on the second computer.