AnsweredAssumed Answered

Add Row to  Existing Point Feature Class

Question asked by W0417127 on Apr 23, 2020
Latest reply on Apr 30, 2020 by W0417127
Hello,
I am having difficulty adding a new row to an existing point feature class using the arcpy.da InsertCursor.
All the fields are populated, except for the ‘Lon’ and ‘Lat’ fields which are given NULL values (‘None’ type).
The existing point feature class was created using arcpy.management.XYTableToPoint. The fc fields are: ['Shape',
'USGS_ID', 'Date', 'Event_Time', 'Magnitude', 'Place', ‘Lon', ‘Lat', 'Depth', 'Update_Time']. 'Lon' and 'Lat' are type Float.
In the call to the InsertCursor, the 'Lon' field was replaced with 'SHAPE@X' and the 'Lat' field with 'SHAPE@Y'.
The 'Shape' field was not included. Input consisted of a tuple of values corresponding to the listed fc fields.
Sample input:
new_event_rows = [('ci39400304', '2020-04-22', '07:03:47.740000', 3.690000057220459,'1km S of View Park-Windsor Hills, CA', -118.34950256347656, 33.98899841308594, 11.600000381469727, 1587616153600.0)].
My code is as follows:
total_new_events = len(new_event_rows)
if total_new_events > 0: # If there are new events to add to the feature class
    with arcpy.da.InsertCursor(base_fc, ['USGS_ID', 'Date','Event_Time', 'Magnitude', 'Place', 'SHAPE@X', 'SHAPE@Y',                                                                                                                                              'Depth','Update_Time']) as irows:
        index = total_new_events - 1
        while index >= 0:
            # Populate new row of base_fc with element (tuple) of new_event_rows
            irows.insertRow(new_event_rows[index])
            index = index - 1
    del irows

I would appreciate your helping me to understand how to use the geometry tokens.
Thank you,
Aleta March

Outcomes