Changing the line direction of line features using the geometry generator in QGIS
Posted by: Admire Nyakudya | in QGIS | 7 years ago | 3 comments

I have been playing around with roads layers and wanted to change the line directions for some of my features. I looked around for solutions to do this in QGIS and saw that I could use the swap vector direction plugin in QGIS or ST_reverse in PostgreSQL. But I wanted to find a non destructive way to do this as I did not want to alter my data. I decided to try the geometry generator in QGIS.

Normal road symbology showing direction.

Road Line Direction

I then set out to reverse the line direction using QGIS Geometry generator.

* Activate the style tab in the layer properties.

* Change symbol layer type from Simple Line to Geometry Generator.

* Change geometry type to LineString/MultiLineString.

* In the expression write  reverse( $geometry )  to reverse the geometry of the features.

* Change Simple Line to Marker line and symbolize the marker line according to your specifications.

* Symbology should appear like the image below:

 

* You have your reversed lines showing in the map canvas as

* A side by side comparison of the roads layers

Current rating: 5

Comments

Comment awaiting approval 4 years, 11 months ago

Comment awaiting approval 4 years, 11 months ago

Comment awaiting approval 4 years, 11 months ago

New Comment

required

required (not published)

optional

required

Have a question? Get in touch!