0

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"
 cursor.updateRow(row)

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?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Apr 4, 2022 at 14:08
1

2 Answers 2

0

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.

answered Apr 4, 2022 at 21:07
0

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.

answered Apr 5, 2022 at 9:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.