Select to view content in your preferred language

Arcade or Python: Calc field to create line between two points

09-11-2023 01:34 PM
Regular Contributor

Does anybody have any ideas in Arcade or Python on how to calc the Unique ID field, like is shown below?  The two points connected by the line have the same Unique ID....



0 Kudos
2 Replies
MVP Frequent Contributor

I'm not really sure what your question is...

  • Do you have a table like this and want to construct the lines?
  • Do you have a coordinate table and want to calculate the ID field like in your example?
# UniqueID = 

# Code Block
i = 0
is_second = True

def get_id():
    global i
    global is_second
    is_second = not is_second
    if not is_second:
        i += 1
    return i

Have a great day!
0 Kudos
New Contributor III

As Johannes said, your question isn't quite clear.

If you're generating the points from lines you could:

- use the Feature Vertices to Points  tool which will generate a feature class of points that contain the original FID of the line they came from.   

- If you have an existing table of points that you want to keep you could then do a spatial join between the table from the tool and your original points and field calculate the  original FID into it.

- Or take the point table generated from the line feature class in the tool and Calculate Geometry attributes for the coordinates.

As a second option you could make a point class from your table and then do a spatial join with the lines and field calc the id into it.


If you have no line feature class, this is just a table and the points are listed in pairs, then use the python script Johannes posted above to assign an ID to each set of points.

0 Kudos