I have created a date field in my point shapefile. I want to input date their. I am able to do so. Now I want to create a sequential increment with 6 second interval from previous point to next point. I have Google it but didn't find any solution. Please help me how can I do it with a huge data set.


Below is code that'll do this at 10.1. You're going to have to figure out which field you want to sort by (i'm using shape_area).

If you wanted to do this with the old cursor (arcpy.UpdateCursor vs arcpy.da.UpdateCursor) the code would be slightly different.

  1. copy your data
  2. modify code below to work with copy of your data


import arcpy
import datetime

tab = r'e:\test\f.gdb\fc1'                        # table being acted on
date  = datetime.datetime(2004, 1, 1, 0, 0, 0)    # start date
delta  = datetime.timedelta(seconds=6)            # time offset

with arcpy.da.UpdateCursor(tab,
                           field_names = ('shape_area', 'datefield',),
                           sql_clause  = ('','ORDER BY shape_area')) as cur:
    for row in cur:
        row[1] = date
        date += delta

See the 'Accumulative and sequential calculations' section in the help file on Calculate Field examples. Convert your date value using the datetime module and use the datetime.timedelta object for the incrementing/adding of 6 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.