works great....I have to code in an edit session for things to work....
This script deletes two fields, recreates with Join (permanent and only brings in X and Y) then moves the points to the new XY coordinates.
- I set my workspace
- Set join variables
- Delete two fields
- Permanent join and add X and Y fields
- Start Edit session
- Use Update Cursor to move the points to the new X and Y coordinates
- Stop and save edit session.
import arcpy
import os
arcpy.env.workspace = "C:\\Users\\xx\\AppData\\Roaming\ESRI\\Desktop10.4\\ArcCatalog\\xx@xx.sde"
print "Started Join"
arcpy.AddMessage("Started Join")
inFeatures = "BR_Boat_Ramp_Inspection_2"
joinField = "ramp_1"
joinTable = "BoatRampsWGS_1"
joinField2 = "SITENAME"
fieldList = ["Lat", "Long"]
arcpy.DeleteField_management(inFeatures, ["Lat", "Long"])
arcpy.JoinField_management (inFeatures, joinField, joinTable, joinField2, fieldList)
fc = "C:\\Users\\xx\\AppData\\Roaming\ESRI\\Desktop10.4\\ArcCatalog\\xx@xx.sde\\BR_Boat_Ramp_Inspection_2"
workspace = os.path.dirname(fc)
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, False)
edit.startOperation()
with arcpy.da.UpdateCursor(inFeatures, ["SHAPE@XY","Long","Lat"]) as cursor:
for row in cursor:
row[0] = ([row[1],row[2]])
cursor.updateRow(row)
edit.stopOperation()
edit.stopEditing(True)