Select to view content in your preferred language

How do I create a new sequence of a point feature based on two corresponding fields?

1674
13
Jump to solution
02-13-2019 02:29 PM
ChristianStallings2
New Contributor II

I have a point file that has two fields with values that represent its neighboring point. We will call them Up for the point above it and down for the point below it for this.  For example Up field is 1205 and the down field is 1201. For the next point in that sequence the up field is 1201 and the down field is 991. For the next point the up is 991 and the down is 977. The down field always indicates correctly the next point in the sequence however the numbers are not sequential. Also to add to the problem, they are string values and they may include a letter such as 981a however there is always a matching value for that in the next point in the opposite field. The final issue is that sometimes the sequence stops which would represent the end of one line feature and a new sequence begins that would represent the beginning of a new line feature.  I would like to build a new field that can properly sequence these points so that I can convert this point file to a line file. Ideally I would like to do this in a way that I can incorporate it into a larger model. I really appreciate any help you can provide or other suggestions on how to approach the problem.

Thanks.

0 Kudos
13 Replies
ChristianStallings2
New Contributor II

Hi Randy,

I just ran this and it worked perfectly! thank you so much for the solution!

ChristianStallings2
New Contributor II

Hi Randy, I was hoping you might be able to help me once more. I've had success with this code up until this point. I've successfully used it in both 2.7 and 3.5 after correcting the print statements however I've hit a wall on a recent file. The fileds are slightly different however the 5 fields that I understand are being used are the same (ObjectID, JOINT___UP, JOINT___DO, LineSeg, SegOrder) I can't figure out what is different but it seems that the keys in the value dictionaries are not working correctly? any help you con provide is greatly appreciated. I've uploaded a GDB that has two files. The one called Weld works correctly however the one called Weld1 does not.

0 Kudos
RandyBurton
MVP Alum

I believe there are some data entry issues with the some of the rows in Weld 1.  I have made some code adjustments in the answer above.  You should replace the while block and the update cursor block.

One of the errors appears to be a circular reference.  I believe that rows 1138 and 1139 should go between 328 and 329.  I suspect an error with the values 533 and 533A.  Since these values follow the 1:1 rule of matching up:down values, neither value was identified as the start and stop of a line segment.  Therefore, it was causing a KeyError in the update cursor.

OID	UP	DOWN	LINE	SEGMENT
330	543	540	1029	37‍‍‍‍‍‍‍ 
329	540	533	1029	38
1138    533A    536A    (circular reference)
1139    536A    533A
328	533	519	1029	39
327	519	527	1029	40
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The second error is a bit more puzzling.  The points are in proximity, but I am not sure how they are connected.  Does the down T-3 connect to row 1158 or 1144. Numerically, 1144 makes sense, but with the 1:1 rule, T3 should only be in the up column once.  And there are two single points that are not connected unless I1220F connects to 1220F.

OID	UP	DOWN	LINE	SEGMENT
1142    1216E   L-11    IJ-2    2
1143    L-11    T-3     IJ-2    3

1156    I1220F  YL-1    I1220F  1
1157    FL-11   1220F   FL-11   1
1158    T-3     FL-2    IJ-2    4

1144    T-3     1216B   ERROR  -1
1145    1216B   FL13    1216B   1‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I would assume the errors are data entry errors.  The code adjustments should help identify some of them.

0 Kudos
ChristianStallings2
New Contributor II

Randy,

 I wanted to apologize for the delay in responding to you. I was out of the office all of this week. I just had a chance to look and the modifications worked perfectly! I should of caught it when I was munging the data. What was actually going on is that there is a T joint in the line. I modified one of the three intersecting lines as well as inserted the modified condition and it worked perfectly. Thank you sincerely for your help!

0 Kudos