0

I have a point feature class like this:
enter image description here
And another table looks like this:
enter image description here
How can I add point's xy coordinate to that table based on their No. and automatic multiply as their No. multiplies using ArcPy?
In the end, it should just looks like this:
enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
citydel
  • 3
  • 1

1 Answers1

1

I like using Python dictionaries. You can house your key and their respective XYs and use the dictionary to update your table.

#point feature class
pointFc = r"point\feature\class"

#update table
tab = r"update\table"

import arcpy

#create dictionary
di = {}

#iterate point feature class and store values
with arcpy.da.SearchCursor (pointFc, ["No", "x", "x"]) as curs:
    for no, x, y in curs:
        #store value
        di [no] = (x, y)

#update table
with arcpy.da.UpdateCursor (tab, ["No", "x", "y"]) as curs:
    for no, x, y in curs:
        #get value from dictionary
        x, y = di [no]
        row = (no, x, y)
        #update table
        curs.updateRow (row)
Emil Brundage
  • 13,859
  • 3
  • 26
  • 62