Alesinar

Calculating offset coordinates of points

Discussion created by Alesinar on Dec 22, 2013
Latest reply on Dec 22, 2013 by Alesinar
Hello!

I have the following problem; I have points feature class that i created from polygons with their coordinates. I would like to calculate for each point the coordinates of the second point at certain distance and at certain angle from the original point. I managed to calculate the offset values for X and Y but I cannot add those values to original coordinates. I was able to do that in ArcMap 10.1 in edit session using calculate field in table however I cannot get python to do the same thing. Python just rounds up the result despite fact that all fields are float.
Here is picture of attribute table where I calculated end_X field with field calculator in ArcMap (that's how I would like the result to loke like) and end_Y field that was calculated using python.
[ATTACH=CONFIG]30065[/ATTACH]

First I tried to do this using cursors (commented out region), after that I opened edit sesion and used calculate field but that also didn't gave the desired result. Here is the relevant part of code:

rows = arcpy.UpdateCursor(depressionsLocation + centerName, "", depressionsLocation + depressionsName.replace('.shp', '.prj'))
for row in rows:
    row.disp_X = (sin(float(row.MBG_Orient))*row.MBG_Length)
    rows.updateRow(row)
del row, rows
rows = arcpy.UpdateCursor(depressionsLocation + centerName, "", depressionsLocation + depressionsName.replace('.shp', '.prj'))
for row in rows:
    row.disp_Y = (cos(float(row.MBG_Orient))*row.MBG_Length)
    rows.updateRow(row)
del row, rows

##rows = arcpy.UpdateCursor(depressionsLocation + centerName, "", depressionsLocation + depressionsName.replace('.shp', '.prj'))
##for row in rows:
##    row.end_X = (float(row.X)+float(row.disp_X))
##    rows.updateRow(row)
##del row, rows
##rows = arcpy.UpdateCursor(depressionsLocation + centerName, "", depressionsLocation + depressionsName.replace('.shp', '.prj'))
##for row in rows:
##    row.end_Y = (float(row.Y)+float(row.disp_Y))
##    rows.updateRow(row)
##del row, rows

edit = arcpy.da.Editor(depressionsLocation)

# Edit session is started without an undo/redo stack for versioned data
#  (for second argument, use False for unversioned data)
edit.startEditing(False, True)

# Start an edit operation
edit.startOperation()

arcpy.CalculateField_management(centerName, "end_X", '!X! + !disp_X!', "PYTHON")

# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)

Attachments

Outcomes