Assuming that pipes are digitizet correctly (first node as upstream, last as downstream), I need to align the arrows of a point layer to display flowmeter's direction. So far I need to use v.split (GRASS), then populate a new field with this expression (see How to horizontally align irregularly shaped point symbol to vector layer in QGIS?):
(atan((xat(-1)-xat(0))/(yat(-1)-yat(0)))) * 180/3.14159 + (180 *(((yat(-1)- yat(0)) < 0) + (((xat(-1)-xat(0)) < 0 AND (yat(-1) - yat(0)) >0)*2)))
and then this angle can be assigned to nearest point with refFunctions plugin:
geomdistance('pipes', 'Angle', 0.001)
Since the flowmeters will be moved to different pipes, I'm looking for a different procedure that will change automatically the angle, I'm open to advices. What comes to my mind is:
- buffer a circumference (radious like 5 meters) around each point,
- select the segment inside buffer
- apply the angle formula to this segment and then write the value as point attribute
Questions are: can it be done? Suggestions in how to do it (preferably with field calculator)?