Changing line direction of line features using Geometry generator in QGIS

Posted by: Admire Nyakudya | in QGIS | 1 month ago | 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 give a try  to 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

Template by Blacktie Mezzanine theme by CodingHouse