jacobne

How to get coordinates from next row?

Discussion created by jacobne on Jul 24, 2012
Hello,

I recently used the CalculateEndTime (http://goo.gl/mJqjG) tool and wanted to attempt something similar but with coordinates.  More specifically,  I'm trying to figure out a way to use the field calculator to get x and y values from the next row.  Technically, the code below works, but it's definitely not pretty... or fast!  Any thoughts or suggestions on how to do this better?

[ATTACH=CONFIG]16390[/ATTACH]

Expression:
calculate_next_y(!OID!)


Code Block:
def calculate_next_y(my_field):

    oid_no = my_field

    rows = arcpy.SearchCursor(r"in_memory\points_mem", "", "", "", "OID; Time_Local")

    for row in rows:

        if row.getValue("OID") == oid_no:
            try:
                next_row = rows.next()
                new_y = next_row.getValue("Latitude")
                break
            except:
                new_y = row.getValue("Latitude")

    return new_y



Thanks!

Attachments

Outcomes