0

I have 40 pour points and want to find out the area upstream of each pour point. I see that I can use the 'Watershed' tool for this. However, I do not want to do this manually. Therefore, I am trying to use ArcPy to delineate the upstream drainage areas in a for loop.

My question is how do I specify the pour point in the Watershed tool? The syntax is:

 outWatershed = Watershed('flowdir', 'pourpoint')

How do I specify the pour points in the for loop? My pour points are contained in a point feature class named 'delineation_points'. I learned that I can use data cursor for this purpose, but I do not understand how? For example,

 cursor = arcpy.da.SearchCursor('delineation_points','*')
 a = cursor.next()

Here, the variable 'a' gives me the field values for the first point in the 'delineation_points' feature class? If I use this as input to the 'Watershed' in place of 'pourpoint', it gives an error:

outWatershed = Watershed('flowdir', a)

I am sure there is something wrong with the way I am giving 'a' as the input.

1 Answer 1

1

The watershed tool wants a feature layer as the second input, you are passing a tuple. You could use the MakeFeatureLayer with a where_clause and an iterator to pass the pour points one at a time to the watershed tool.

However you don't have to do it one pour point at a time. Add all the pour points to the watershed tool, make sure you also add the unique numeric field to identify the pourpoint.

Watershed('flowdir', 'delineation_points', 'your Unique numeric pour_point_field')
1
  • Thanks, Mark. I will use MakeFeatureLayer. I have to use the pour points separately, otherwise, the tool gives direct contributing drainage area rather than total drainage area. I will accept the answer once I have successfully used MakeFeatureLayer tool. Commented Mar 20, 2023 at 22:08

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.