I have a destination (Feature Class):
C:/Users/XXX/Documents/ArcGIS/ABC.gdb/SamplePoints
I have a database table in the same file geodatabase that contains my source point data. I have columns with attributes in addition to the requisite coordinate data.
Using Arcpy, how do I retrieve the points from the source database table and create points in the destination Feature Class?
I tried creating a single point using this code:
import arcpy
cur = arcpy.InsertCursor(fc, ["SHAPE@XY"])
pnt = arcpy.Point()
pnt.x = 20000
pnt.y = 10000
feat = cur.newRow()
feat.shape = pnt
cur.insertRow(feat)
del cur
but, although a row is created, the coordinates are 0,0.
Current thoughts – I'll probably use a cursor to step through the records retrieved and for each row in the source, build a point and insert it into the destination. The logic seems to make sense.
Best Answer
I am not sure whether nested cursors (e.g. a SearchCursor for the source table and an InsertCursor for the destination feature class) will work, but it's worth a shot.
Specific to your problem of how to get geometry data into a feature class using an InsertCursor:
Use a da.InsertCursor (since you have access to 10.1+)
Take a look at the Help page for arcpy.da.InsertCursor, particularly the examples. I think that you are making it more complex than necessary.
This is their example. No geometry objects needed, just the numeric values.