5

I've digitised some symbols in QGIS (2.14.1) as a new Shapefile point layer. I want the symbols to be rotated to different angles.

I've worked out that I can have a data defined rotation field in my attribute table and I've put this in and it seems to be working. However I can't workout if there is a way to rotate the symbol in the map window and have that update in the attribute table: so I'm stuck with putting values into my attribute table manually.

I know how I can rotate label with the Label Toolbar so I really hope that there is a similar function for symbol rotation.

2

In QGIS 2.18+ (and QGIS 3) this is a built in feature.

Create the layer as before:

enter image description here

With a rotation column that has 0 to begin with. Make sure to set up the data defined override for the symbology. In my case I did it for both the square and the question mark that made up my symbology.

Then using the "Rotate Point Symbols" tool from the advanced digitizing toolbar. You can rotate the point.

enter image description here

enter image description here

Success:

enter image description here

  • 1
    The "Rotate Point Symbols" tool from the advanced digitizing toolbar is also available in QGIS 2.18.16. – Stefan Mar 16 '18 at 12:58
2

So this would be the workaround for 2.14.x as asked in the question.

An advantages over "Rotate Point Symbols": With the (end)-node of the rotating line you can directly point to another object and snap it. IMO with the "Rotate Point Symbols" it is not possible to use the right rotating angle when you point an object with the cursor.

enter image description here

You can achieve this easily with the use of an additional vector line layer. The idea is to assign an angle value from a line you create to the point layer symbol via joining both layers.

Edited - I've post another workflow at the bottom of this answer which uses the awesome QGIS plugin AutoFields from German Carrillo.

This plugin allows you to configure vector fields to be automatically calculated for you when digitizing new features or modifying existing ones. Think about them as triggers in a database or as an automatic Field Calculator.

Also:

On which QGIS versions does AutoFields plugin work? You can use AutoFields on QGIS v2.12.x or greater. Although you need v2.14.x if you want to get geometric properties (e.g., area, length, and perimeter) converted from layer CRS (Coordinate Reference System) units to units defined in the QGIS project.

Working example:

I. Having a point layer symbol_point with 5 features and the corresponding attributes id (for joining), angle (stands for the old given angle), descr.

II. Having a line layer rotation_line holding the attributes id (for joining), line_angle.

Workflow 1 - without using external plugins, only works on insert a line not on changing the geometry.

  1. Enable snapping on the point layer: Settings > Snapping Options > Layer selection: Advanced. Choose your layer and set Mode to vertex and the tolerance.

  2. Go to Properties > Fields > Text Edit of the field line_angle of the line layer. There you set the Default Value to to_int(degrees(azimuth(start_point($geometry ),end_point($geometry)))) like shown in this picture. This updates the field line_angle after you've create the line with the azimuth of the line. You have to start at the point, otherwise you get the "opposite" azimuth!

enter image description here

  1. Set the join in the Properties of the point layer: Join layer rotation_line with join field id and target field id (from the point_layer). The field line_angle from the line layer should be joined.

enter image description here

  1. Choose the new field rotation_line_line_angle as a data defined override for the symbol rotation in the Style Properties

  2. Enable editing on the line layer and create a line starting from the point (should be snapped) and with the azimuth you want using the courser. You don't have to care about the length of the line. Important is the azimuth of the line. You have to enter the same id the point has. See the picture here. The line_angle is set automatically. After clicking OK the point symbol should be changed to the angle of the line.

enter image description here

enter image description here

Workflow 2 - with plugin AutoFields

  1. You don't have to use Step 2 in Workflow 1
  2. Use Plugin AutoFields as follows: a) select rotation_line in the Layers window b) enable Existing Field in the field window and choose field line_angle c) enable Custom Expression in the value/expression window and paste to_int(degrees(azimuth(start_point($geometry ),end_point($geometry)))) in the expression field.

Having the join set from workflow 1 the point symbol changes immediately when you change the rotation of the line with the node tool.

1

For showing respective rotation to the symbols first you need to have rotation value for every points in the attribute table. Then go to properties style tab click on symbol Then on the right hand side of the rotation click on data defined override. then under field type select your respective rotation column name. Then click on apply button. enter image description here

  • 1
    Welcome! The asker already did this — the question was whether there's a way to make manual overrides on the map be automatically reflected in the attribute table. – lynxlynxlynx Mar 16 '18 at 7:17

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.