Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

Thanks

share|improve this question
add comment

2 Answers 2

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.

share|improve this answer
add comment

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
        cur.updateRow(row)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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