I would like to present in QGIS a graphical information I have in two vector layers, an arrow. One layer has catchemnt areas as polygons and the other has the outlet points. The catchment areas layer has the ID of the outlet points in its Atribute Tables. The question is how to present an arrow rom the centroid to the point.
The background of the question is the SWMM model. In the picture below the yellow area points to node J3 and I want to draw that line.
In my case I have a subcatchment layer ('CatchmentAreas') with an attribute table like this:
fid Name RainGage Outlet
1 Sub_01 Rainfall 43
2 Sub_02 Rainfall 38
3 Sub_03 Rainfall 73
and a outlet layer ('Junctions') like this:
id DESC INV_ELEV
43 desc1 3.96
73 desc2 3.77
38 desc3 3.75
Outlet
matches id
Answer
You can use a virtual layer to automatically create such a line, then you can style it as an arrow.
The following example assume the polygon layer is named CatchmentAreas
, the point layer is called Junctions
and the outlet ID column is called Outlet
in CatchmentAreas
and id
in Junctions
.
Go to the layer
menu, edit layer / add-edit virtual layer
and paste the new layer definition:
select make_line(st_centroid(CatchmentAreas.geometry),Junctions.geometry)
from CatchmentAreas, Junctions
where CatchmentAreas.Outlet = Junctions.id
This code joins the two layers based on the point ID, then it computes the centroid of the polygon and at last it builds a line between the centroid and the matching point.
Then you can style the new layer so it displays arrows
No comments:
Post a Comment