2

enter image description here

enter image description here

As you can see in the picture, is there any way to calculate angle of a river cross section profile from right side of the river profile with respect to the flow direction till the north axes in QGIS

maiyourathaan
  • 305
  • 1
  • 8
  • See this post. https://gis.stackexchange.com/questions/24260/adding-direction-and-distance-into-attribute-table – GBG Feb 03 '22 at 15:28
  • To me, the question is unclear, I'm not sure which angle you mean. Please be more clear or see here if that helps: https://gis.stackexchange.com/questions/397497/calculating-interior-angles-of-polygons-or-lines-in-qgis – Babel Feb 05 '22 at 13:50
  • I want to calculate the angle that covers this 3 points
    1. X=0 (Right side of the river poly line)

    2)Middle point of the river 3) North vertical line (N) Angle has to be calculated in this order

    – maiyourathaan Feb 25 '22 at 07:50
  • 1
    I am confused by the image in your post. Black lines, red lines, green lines, some seem to contradict each other. It would really help if you edited your post with a new, simpler graphic that focused on the specific angle that you desire. Also describe your existing data. For example, do the river profiles already exist as a layer, or do they need to be created? – Stu Smith Feb 25 '22 at 15:51
  • @StuSmith I have the data of the river centreline (Blue), cross section of the river as a line (green), and I want to calculate the angle that form my cross section with respect to North ( I made it in the sketch as a purple colour right angle) The angle should be calculated from the right side of the flow direction from the cross section till the North axis. (In this case from X=0 till North) For example, if my river flow from Southeast to Northwest, i need my angles to be calculated from the right side of the river cross section profile, in this case X=30 till the North axis. – maiyourathaan Mar 01 '22 at 07:12
  • I'd like to help, but you still have not answered my previous question... – Stu Smith Mar 01 '22 at 16:33
  • @Stu Smith I have river cross section and river centreline as data, I also updated the sketch, does it help you to visualise the problem – maiyourathaan Mar 02 '22 at 07:26

1 Answers1

1

Thanks for updating your screenshot; it helped!

The following is one way to solve your problem. To help, I created a hypothetical layer, named stream, shown below. Even though it twists and turns, you can see that it has just one record. Because it only has one record, it is not possible to determine the angle value for each segment. Note also that I digitized the stream in one direction, as indicated by the ending arrow. It is critical that this direction is always downstream!

enter image description here

Creating your crossing angles took several steps. First, I created a new layer, stream_exploded, where each stream segment has its own record, using the Processing > Toolbox > Vector Geometry > Explode Lines tool. The input layer was stream. The output is shown below. Note that there are now eight records, one for each stream segment. This means that the angle for each stream segment can now be calculated.

Next, I edited the stream_exploded attribute table by adding a new integer field named stream_angle. Using the Field Calculator, I calculated stream_angle = line_interpolate_angle($geometry,0). This value represents the angle of each stream segment from north, as it flows downstream, and is represented by the first number in each label.

Now that the downstream angle is known, I created a new integer field named cross_angle. It represents the river profile angle, perpendicular to stream_angle, with respect to north. I determined cross_angle using a series of attribute selections followed by the Field Calculator, as follows:

1a. Attribute selection:

("stream_angle" > 0 AND "stream_angle" < 90) OR ("stream_angle" > 90 AND "stream_angle" < 180)

1b. Field Calculator:

"cross_angle" = "stream_angle" + 90

2a. Attribute selection:

("stream_angle" > 180 AND "stream_angle" < 270) OR ("stream_angle" > 270 AND "stream_angle" < 360)

2b. Field Calculator:

"cross_angle" = "stream_angle" - 270

3a. Attribute selection:

"stream_angle" = 180

3b. Field Calculator

"cross_angle" = "stream_angle" - 90

4a. Attribute selection:

"stream_angle" = 0 OR "stream_angle" = 90 OR "stream_angle" = 270

4b. Field Calculator

"cross_angle" = "stream_angle"

Voila! cross_angle is represented by the second number in each label.

Please check my selection criteria and math to make sure that it meets your needs!

enter image description here

You'll note that my approach assumes that profiles cross stream segments between vertices. If your profiles cross at vertices, refer to these SE-GIS posts:

Extract vertices QGIS 3

Calculating interior angles of polygons or lines in QGIS

Stu Smith
  • 8,252
  • 8
  • 35
  • 84