I want to create a ModelBuilder tool that I can use to save my time when I need to populate a ward name into my asset layers.

Here Ward is a Polygon feature layer and my asset layers can be point, line or polygon. Ward polygon layer has 14 different wards in my selected area and the asset layers (point, line, polygon) are distributed randomly everywhere in those wards.

I'm relatively new to ModelBuilder in ArcGIS Pro.

I don't want to create a new dataset, I want to update the existing enterprise geodatabase feature class using SelectByLocation method.

My script looks like as below;

pts = "E:\Map Documents\DATABASE CONNECTIONS - SQL SERVER\Default.gdb\British_National_Grid\BL_Bollard" 
poly = "E:\Map Documents\DATABASE CONNECTIONS - SQL SERVER\Portsmouth.sde\Portsmouth.DBO.Road_Network\Portsmouth.DBO.PortsmouthWards"
fieldname = "ElectoralWard"
arcpy.management.SelectLayerByLocation(pts, "INTERSECT", poly, None, "NEW_SELECTION", "NOT_INVERT")
with arcpy.da.UpdateCursor(pts,fieldname) as cursor:
    for row in cursor:
        row[0] = "Hilsea"

It works very well but populate the single value "Hilsea" in all rows. I don't know how to use if/elif class.

Can anyone guide me on this?


2 Answers 2


A single tool could copy the Ward name into your asset layer but it creates a new dataset, explore the Spatial Join tool, so no need for using model builder.


If your assets are not contained inside one single ward, and you want to split your assets along the ward limits, you can also look into the Intersect tool. Just like Spatial Join, it will create a new dataset.

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.