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

  • I don't think "multiply" means what you think it means. Perhaps you mean join? – Kirk Kuykendall Jun 17 at 14:29
  • @KirkKuykendall I tried join and I think join means one to one, but I want one to many. – citydel Jun 17 at 15:15
  • Do you want new points feature class, or just update the table with the values? – smiller Jun 17 at 16:15
  • @smiller Actually I want a new point feature class, but update the table with the values is also fine, I can generate point later as well. – citydel Jun 18 at 1:53
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)
  • That's really helping! Thank you! – citydel Jun 18 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.