I am attempting to calculate point stationing (footage) along a pipeline at a set interval via python script, thing is I'm just now learning to code in Python, I come from a VBA programming background. In regards to this exercise I will be creating an empty file geodatabase, within this database I will be creating an empty feature class table. This feature class table will contain an empty field/column named, "Calculated Footage". My desired result is to populate the content of my feature clas table via Python script such as the ones below.
I have been successful in obtaining the desired results within a python list as shown below but when attempting to do so in a file geodatabase I seem to be at a lost. Simply put how do I go about applying the logic below to the "Calculated Footage" field in my feature class table? In other words how do I populate the "Calculated Footage" field with the result of my while loop? I'm simply trying to append, load or insert data into the field in question
B_Measure = 0; E_Measure = 5280
Curr_Measure = 0; Interval = 1000
My_List=[]
C_Measure = 0
# Body of the Main program
while abs(E_Measure-C_Measure)>Interval:
if My_List==[]:
My_List.append(C_Measure)
print C_Measure
else:
C_Measure=C_Measure + Interval
My_List.append(C_Measure)
print C_Measure[/CODE]
I've done this exercise in Excel as well, using the following VBA Code.
Sub Calculate_Footage()
'Declaring variables
Dim X, Y, Beginning_Point, Ending_Point, Interval, Current_Point As Integer
'Assigning initial value to variables
X = 2
Y = 1
Beginning_Point = 0
Ending_Point = 5280
Interval = 1000
Current_Point = 0
'Assign Field/Column Name
Cells(1, 1).Value = "Calculated Footage"
'This While Loop will populate my "Calculated Footage" field
Do While (Ending_Point - Current_Point) > Interval
Current_Point = Current_Point + Interval
Cells(X, Y).Value = Current_Point
'Move to the next row but same column
X = X + 1
Loop
End Sub
Current Python Code # Import system modules import arcpy from arcpy import env
# Set workspace in which to create geodatabase
env.workspace = "C:/data"
# Set local variables
out_folder_path = "C:/data"
out_name = "fGDB.gdb"
# Execute CreateFileGDB
arcpy.CreateFileGDB_management(out_folder_path, out_name)
# Set environment settings for Table in geodatabase
in_database = out_folder_path+"/"+out_name
table_Name = "Custom_Stationing"
arcpy.CreateFeatureclass_management(in_database, table_Name)
# Set workspace for Add Field
in_Table = in_database+"/"+table_Name
Field_Names=["Route_Id","Route_Code","Series","Measure","Calculated_Field"]
for n in Field_Names:
arcpy.AddField_management(in_Table, n)
I would like to apply the following code sample to insert rows located hereINSert Cursor