I need to create a shapefile (or merge 2 shapefiles) with different styles for both line width and label.

They represent both main river (with style A) and secondary river (with style B) and I want to save the styles on an sld file so when I open it later I can see the different styles.

How can I achieve this?

I am using QGIS 2.18

  • 3
    Line style is not a property of a shapefile. No symolization is. That's the fundamental difference between CAD and GIS.
    – Vince
    Feb 1 '18 at 13:15

This question is a little unclear but here are some steps that should hopefully help:

  1. You need to be able to differentiate between the two river types, do both shapefiles have a column with the same label, for instance "type", in the attribute table that identifies them as "main_river" or "sec_river"?

  2. If shapefiles do not have such a column you will need to use the field calculator to add a new string column to each shapefile, calling it something like "type", and then adding the entry "main_river" or "sec_river depending on the shapefile.

  3. You then need to merge the two shapefiles. You should end up with one single shapefile with a single column called "type" with either river type as the row entries.

  4. You now need to go into Layer Properties and then to Style, select Categorized from the top drop down and select the column from before, you should then be able to style each river type separately.

enter image description here

  1. You don't need to save the style as a sld or qml in this case. However if you do want to save it for backup purposes go to Layer Properties and then Style and in the bottom left hand corner you can save the style.

enter image description here

  • Great. It worked as expected.
    – pmatos
    Feb 1 '18 at 12:42

To add to @Trashmonks answer. You can use a rule-based labeling for the labels.

  • I've created a shapefile with a field "class" and three lines with the values 1,2,3
  • Go to labels and choose rule-based labeling and a rule for each different label you want. As rule you would do something like "field_name" = 'value' where value is text or "field_name" = 42 when the values in the field are numbers
  • The text can either something static like in my example or a value from a field
  • You then can style to your liking.

The result looks like this:

enter image description here

  • Thank you very much. This way I am in control of labeling.
    – pmatos
    Feb 2 '18 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.