I have some code that seems to behave as expected and occasionally satisfies an if loop i've created but the code never seems to enter the loop. Even where the if statement is satisfied. Any help would be appreciated. The 'Warning' Messages a just to trigger a different font effect in the display box as the tool runs. The if statement at line 21 in the attached file is the issue, though as I've said it triggers no errors.
Solved! Go to Solution.
I have come up with an approach to automate pour point creation with slight setbacks from a given stream's delineated outlet (this was the intent):
1. Create a point layer with points for each vertice in the stream network layer
2. Buffer each vertice a (small) desired amount (i arbitrarily chose 10 metres)
3. Run intersect and create points as the output, this will create a series of points where the buffer intersects the stream layer at the setback amount.
4. Identify which points of intersection are of the desired order or greater. Remove those that are not.
5. Identify the smallest remaining order within the buffer. Any points greater than the smallest order (i.e the stream being flowed into) will be removed.
6. Left with the smallest order points which are greater than the specified minimum order of concern.
7. These are the pour points (automated). I snapped the pour points back half of the original setback (5m). So the pour point should be 5 or so metres from the actual outlet (dependent on the shape of the stream), which makes for clean delineation.
Hoping the brief description is clear.
I'm not, the script is certainly not entering the statement at line 22 or 25. I'm thinking this is the issue, but I can't identify any issues with the syntax? Further, if I am entering the statement at 21, should I not be entering the else if the 'if' on 22 is repeatedly false? I would expect some error if I were appending to a file which doesn't exist...
Are you seeing the message generated by arcpy.AddMessage in lines 19-20? And likewise, are you seeing the arcpy.AddWarning messages from lines 23, 26 and 31? You may need to use GetMessages.
And what are some of those messages?
All messages are coming through less 23, 26 and 31. Is my syntax for the if loop on line 22 correct? I'm looking to confirm a dataset is there and if not create one. Most of the messages are to give users in the office an idea of whats going on without having to interact with python.. The message on line 19 was added to confirm the different elements of the if statement on line 21 are being passed in correctly - they seem to pass in fine. I apologize for the difficulty in reading the code, this has expanded to a larger script than anticipated and my experience in python is not extensive.
I see where Randy is going, you say the values are being passing just fine, but it seems you are doing that by looking at the variables and not by having code between lines 21 and 22 actually add a message.
Add an else at the end of your script (match the indentation of your "if Point ==...."
for Point in Points: arcpy.AddMessage( .... ) if Point == orders and Point >= Minimum_Stream_Order_To_Delineate: if arcpy.Exists(Final_PP_Layer + "_O" + Point): stuff else: more stuff # add an else here to check if point, orders and Min_Stream... meets criteria else: AddMessage ... "Failed"