2

Background: Sometimes in modelling hydrology (e.g. in SWMM) we have runon from one subcatchment area to another. These subcatchments are records in a shapefile. I want to show this situation as a line from the centroid of one polygon to another (the "outlet"). This is what I tried (which obviously doesn't work):

select make_line(st_centroid(Subcatchments.geometry),st_centroid(Subcatchments.geometry))
from Subcatchments
where Subcatchments.OUTLET = Subcatchments.Name

Can anybody assist me in how to do this correctly?

1 Answer 1

1

The trick is to join the layer to itself:

SELECT make_line(st_centroid(s1.geometry),st_centroid(s2.geometry))
FROM Subcatchments s1
JOIN Subcatchments s2 
 ON s1.OUTLET = s2.Name
1
  • Thanks! This was exactly what I was trying to do–I just couldn't quite figure out how. Commented Feb 2, 2024 at 23:00

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.