1

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.

enter image description here

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

3
  • Is your question "how to automatically make an arrow from all my polygon centroïd to all my outlet points" ?
    – Snaileater
    Commented May 24, 2018 at 10:53
  • I am not sure if "automatically" is the right word, but certainly I meant for all pairs. I do not know is it better with a set of instructions, a plug-in or a a virtual layer based on a SQL query, but it should be fast becuase it is just an auxiliary information I want for all pairs
    – Marco
    Commented May 24, 2018 at 11:40
  • but are you able to build the "logic" linking the polygon centroids to the outlet points ? (and to prepare the table for that ?)
    – Snaileater
    Commented May 24, 2018 at 11:42

2 Answers 2

3

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 enter image description here

0

I think you will have to prepare an origin-destination table with all the start points and endpoints of the arrows you have to create.

Then you have some plug-in able to generate the line based on this origin-destination table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.