I don't know if my mistake is of a general nature. I come from R where it is very easy to store a vector in a matrix column. So now I (new to coding with arcpy) am desperately trying to do the same thing in ArcGIS.
I have a point feature class to which I have added a new field ("new_ID"). I want this new field to be filled with a sequence of numbers from 1 to [number of items in my FeatureClass].
Question: Is it possible to assign a vector to the new field?
The source of my problem is: I need to move and sometimes delete points in a feature class. After deleting them the column OBJECTID obviously doesn't contain a straight sequence anymore. For example: my points feature class contains 10 points, I delete point number 5, so my column OBJECTID goes like: 1,2,3,4 , 6,7,8,9,10 (5 is missing). For specific reasons I need a straight sequence of numbers. In that case after the deletion of point number 5: from 1 to 9.
I couldn't find any help in the search section. So I wonder if this problem ever occured to someone else? Am I just still to much in R? Would you solve this issue in ArcGIS completely differently? Or am I just overlooking something crucial?
I'm also unsure about which tool to use. UpdateCursor? CalculateField? JoinField?
Here's what I tried:
>>> sum = arcpy.GetCount_management("my_featureClass") sum = int(sum.getOutput(0)) input_field = range(1, sum + 1) >>> cursor = arcpy.UpdateCursor("my_featureClass") for i in curs: i.new_ID = input_field curs.updateRow(i)
ValueError: Row: Invalid input value for setting
>>> cursor = arcpy.UpdateCursor("my_featureClass") for i in curs: i.new_ID = input_field[i] curs.updateRow(i)
TypeError: list indices must be integers, not Row
>>> cursor = arcpy.UpdateCursor("my_featureClass") for i in curs: i.new_ID = int(input_field) curs.updateRow(i)
TypeError: int() argument must be a string or a number, not 'list'
I understand why all three don't work but I don't see a solution.