Select to view content in your preferred language

How to get relationship of cities being upstream or downstream from each other?

673
1
10-15-2020 02:45 PM
AdamN
by
Emerging Contributor

I'm interested in examining cities (points) and rivers (lines) within each watershed (polygons) in the country of Colombia. I've performed a spatial join between the cities and the watersheds so the cities have the information about the watershed they are in.

As a final output, I'd like the city attribute table to contain two additional columns: cities that are upstream and cities that are downstream. These two columns only need to contain info about other cities in their watershed:

One path I've gone down is to create a trace network and enable network topology. To do this I've snapped all city points to the nearest river vertex within a half mile:

I've looked into the diagrams that can be created from a trace network, but have been unable to create the desired output.

Should I be looking into another workflow?

0 Kudos
1 Reply
TimWhiteaker
Frequent Contributor

In theory, the trace network would serve your needs.  I'm actually trying to do something similar.  The general procedure would be to build a trace network with your snapped cities and rivers.  Then you would iterate through each city, and do the following:

1. Set the city as a starting point.

2. Trace upstream.

3. Collect and names of the upstream cities that were returned in the trace. They would be returned in the form of a feature selection on the city layer.

4. Concatenate the names in a comma separated list and write to the Cities Upstream field in the city layer.

5. Trace downstream.

6. Collect the names downstream.

7. Write the names to the Cities Downstream field.

(In fact, if you iterate through all cities and trace upstream, you can use that information to also build the list of cities downstream, but conceptually it's just easier to do steps 5, 6, and 7, albeit probably slower from a scripting standpoint).

However, in practice I'm struggling to get the iteration working in ModelBuilder.  I may wait a few days to see if any experts have solutions.  Things may be better in Pro 2.7, but my client will be at 2.6 for a while so I'm stuck for now.  If a ModelBuilder solution doesn't present itself, I'll try Python instead.

0 Kudos