Arcpy write geometry error

2061
10
02-16-2017 08:06 AM
DEVAPP
by
New Contributor III

Hi guys,

i have develop a python script that use the cursor to read the geometry by one FC and write this geometry into temporal layer create by Make Route Event Layer.

The FC where i read geometry is a Multipoint and also my temporal layer is Multipoint. I have write this code:

field_1 = ["ID"]
field_2 = ["SHAPE@","SHAPE@X","SHAPE@Y","ID","SHAPE@XY"]

for row in arcpy.da.SearchCursor("tab_loc_lyr", field_1):
    where = "ID = '" + str(row[0])+"'"
    select = arcpy.SelectLayerByAttribute_management("loc", "NEW_SELECTION", where)
    for row_ in arcpy.da.SearchCursor(select, field_2):
        icur = arcpy.InsertCursor("event_lyr")
        irow = icur.newRow()
        irow.Shape = row_[0]
        irow.ID = row_[3]
        icur.insertRow(irow)

if i try the code without insert geometry works finie but if i try also to write the geometry with:

irow.Shape = row_[0]

i recive this error:

irow.Shape = row_[0]
  File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\arcobjects\_base.py", line 35, in __setattr__
    return setattr(self._arc_object, attr, ao)
RuntimeError: ERROR 999999: Error executing function.

Any hep please???

Thanks

0 Kudos
10 Replies
JoshuaBixby
MVP Esteemed Contributor

You can use ArcPy Geometry class with the Select by Location tool.  For example, you can pass the tool an ArcPy Point as the selection feature and have the tool select all polygons in a feature class that intersect that Point object.

0 Kudos