In the left panel double click on the layer and the box "Layer Properties" appears.

 

 

In "Layer Properties" at the bottom there are 4 buttons. All 4 buttons has something to do with saving and adding layer settings.

These buttons appears no matter what you choose in the left panel.

We will go through these 4 buttons below with a simple example.

 

 

We want to save a style, where the houses are red, so we will change the color to red.

We want to save this layer style, so we click on "Save Style ...".

As you can see on the picture above, you can save in 3 different ways.

 

 

If you click on "QGIS Layer Style File", this box will appear. This way you will save the layer style as a QGIS layer style file.

 

 

If you click on "SLD File", this box will appear. In this case the layer style is saved as a .sld file.

 

 

We will choose the last option, which is "Save in database (postgres)". This means we are saving the layer style in the Postgres database. (This option is only available, when you are working in a database layer as PostGIS. This option is not available, if you are working in an ESRI Shape layer.)

We name the layer style "Reydir bygningar" and click on "OK".

 

 

We will then create another layer style.

We choose "Categorized".

Under "Column" we choose "slag".

We choose a "Color ramp" by our own choice.

Then click on "Classify".

Now we created a new layer style, where the main buildings became yellow, and other smaller building types became blue.

We save this layer style the same way, as we saved the first one. Click on "Save Style" and choose "Save in database (postgres)".

 

 

We name the layer style "Slag av bygningi" and click on "OK".

Now we have 2 layer styles: "Reydir bygningar" and "Slag av bygningi".

 

 

"Slag av bygningi" is now the active layer style.

When we load layer styles, we use the button "Load Style ...".

If you are working in a PostGIS layer, you can load from a file or from the database.

If you are working in an ESRI Shape layer, you can load from a QGIS layer style file.

Click on "Load Style ...".

 

 

If you choose "Load from file" this box will appear. Then you can load from a QGIS layer style file, but this is not, what we will use this time.

  

 

We choose "Load from database" and this box appears. It means we choosed to load from the database(This option is not available, if you are working in an ESRI Shape layer.)

Please notice, that you receive a list with all the layer styles in the database.

You see layer styles, which are related to the layer, you work with, but you also see all the other layer styles in the database.

We now choose "Reydir bygningar" and click on "Load Style". 

 

 

Now "Reydir bygningar" has become the active layer style.

 

 

And we can also see this on the map. The buildings are red.

 

 

Again we click on "Load Style ..." and "Load from database".

 

 

This time we choose "Slag av bygningi" and click on "Load Style". 

 

 

And now we can see, that "Slag av bygningi" has become the active layer style.

 

 

We can also see this on the map. The houses are yellow, and the smaller buildings are green/blue.

This is how you can switch between layer styles.

 

 

Then which layer style is active, when we add a layer into QGIS ?

It is the layer style, which is saved as default.

We now click on the button "Save As Default".

 

 

If you are working in a PostGIS layer, you will now get the option, either to save the layer style to the original database ("Datasource database") or to your "local" database ("Local database"). If you choose "Datasource database" the layer style is saved in the PostGIS database. If you choose "Local database" the layer style is saved in a file on your own computer.

If you are working in an ESRI shape layer, the layer style is saved in a QGIS layer style file. (.qml)

We now said, that the layer style "Slag av bygningi" should be "default".

 

 

 

Again we click on "Load Style ..." and "Load from database".

 

 

We choose "Reydir bygningar" and click on "Load Style".

 

 

 

Now the layer style "Reydir bygningar" again became the active one.

The button "Restore Default Style" is used to go back to the default layer style.

Click on "Restore Default Style".

 

 

 

If you are working in a PostGIS layer, you need to choose, if you want to load the original layer style from the original database (PostGIS) or from your "local" database (a file on your own computer).

  

 

And now "Slag av bygningi" again became the active layer style, because it was "Slag av bygningi", which we saved as default layer style before.

 

Style and Project

The style you save with the "Save as default" button, is the style loading (default) next time you open the layer in QGIS.

However, when you save your work as a project, the project saves the layer style, which is used at the same moment as the project is saved.

Then when you open the project again, it is the layer style in the project, that loads (default).

This means that a project overrules a default style in database or file.

 

You are welcome to write comments below. If you have any questions, please post in the forum.

 << Joins
Load / save layer style