update the location of the point based on an attribute/tracking system

115
1
03-25-2020 11:45 AM
PawełPleń
New Contributor

Hello guys,

Im working on Pipe Tracking System and need to manage how to change the location of the point after scane the same barcode in Collector for ArcGIS. Do anybody know how to update the location of the point based on an attribute?

The point is to show on the map location of every pice of pipe only once --> track the location of every pice of pipe (not to multiply it).

Pawel

0 Kudos
1 Reply
TimothyMichael
Occasional Contributor II

Pawel,

If you have the new coordinates as field attributes, you could use a python script to update the location of the feature.  Something like this could work:

import arcpy
import sys
import time
import traceback

# Capture start time
tStart = time.time()

# Workspace, target feature class, and fields variables
# Coordinate fields in attribute table should be of type 'Double'
arcpy.env.workspace = r'C:\TEMP\PointMoveTest.gdb'
fc = r'C:\TEMP\PointMoveTest.gdb\AddressPointsModified'
fields = ['SHAPE@X', 'SHAPE@Y', 'gps_x', 'gps_y']

try:
# Create update cursor for feature class
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:

# Set X, Y values to fields in 'fields' variable
row[0] = row[2]
row[1] = row[3]

# Update the row
cursor.updateRow(row)

except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
print(msgs)

except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
print(pymsg)
print(msgs)

# Capture end time and calculate elapsed time
tEnd = time.time()
elapsedTime = round(tEnd - tStart, 2)

print 'Script completed in {0} seconds'.format(elapsedTime)

--Tim

https://www.geo-jobe.com/ 

0 Kudos