I have a point feature class like this:

And another table looks like this:

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:

Asked
Active
Viewed 58 times
0
-
See https://gis.stackexchange.com/questions/2037/creating-duplicate-features-based-on-many-to-one-conversion-of-related-table – SMiller Jun 17 '19 at 14:27
-
I don't think "multiply" means what you think it means. Perhaps you mean join? – Kirk Kuykendall Jun 17 '19 at 14:29
-
@KirkKuykendall I tried join and I think join means one to one, but I want one to many. – citydel Jun 17 '19 at 15:15
-
Do you want new points feature class, or just update the table with the values? – SMiller Jun 17 '19 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 '19 at 01:53
1 Answers
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