0

I am trying to add new point from table using XY coordinates fields to database. I can add point without fields, but when i try to add point with field values i can not do it. In SearchCursor ID is a field from data table and in InsertCursor 'dazianebis_tipi' is a field I want to update by ID field. Here is code i use:

with arcpy.da.SearchCursor("Watersupply_GWP.DBO.%GIS_ACCIDENTS",["PointCoordinateX","PointCoordinateY","ID"])as cursor:
             for row in cursor:
                 point.X = row[0]
                 point.Y = row[1]
                 req_ID  = row[2]
                 
                 rowValues = [[req_ID,((point_Geometry_out.centroid.X),( point_Geometry_out.centroid.Y))]]
                 
                 cur = arcpy.da.InsertCursor(fcc,['dazianebis_tipi','SHAPE@XY'])
                 for row in rowValues:
                     cur.insertRow(row)
1
  • Even if you ran your code from the Python window of ArcMap, please remove the ellipses at the beginning of each line so that the code you present can be copy/pasted for easier testing by any potential answerers.
    – PolyGeo
    Commented Dec 4, 2021 at 7:08

1 Answer 1

0

I have just used double quotes for field dazianebis_tipi in InsertCursor and it works perfect now:

with arcpy.da.SearchCursor("Watersupply_GWP.DBO.%GIS_ACCIDENTS",["PointCoordinateX","PointCoordinateY","ID"])as cursor:
     for row in cursor:
         point.X = row[0]
         point.Y = row[1]
         req_ID = row[2]
                 
         rowValues = [[req_ID,((point_Geometry_out.centroid.X),( point_Geometry_out.centroid.Y))]]
         #xy = ["SHAPE@X","SHAPE@Y"]
         cur = arcpy.da.InsertCursor(fcc,["dazianebis_tipi","SHAPE@XY"])
         for row in rowValues:
             cur.insertRow(row)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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