-1

I just want to try to use a Python script to select specific roads in my Layer called "Route_01_Shatin" and so I coded as below:

arcpy.management.SelectLayerByAttribute('Route_01_Shatin', 'NEW_SELECTION', "\"ALIAS_ENAM\" = \'Roadabout\'")

but then when I ran it, I did not receive any error messages but none of the roads are selected.

What is my problem?

3
  • 2
    Does that field have values of Roadabout or might they be Roundabout?
    – PolyGeo
    Feb 16, 2020 at 5:56
  • You don't need to escape single-quotes inside a double-quote string.
    – Vince
    Feb 16, 2020 at 11:57
  • Does it work if you select by attributes using the same clause in Pro directly, without a script? Is the layer in a shapefile or database? Feb 16, 2020 at 21:15

1 Answer 1

0

If your field named ALIAS_ENAM of your layer named Route_01_Shatin has any values of 'Roadabout', then I think this should work:

arcpy.management.SelectLayerByAttribute('Route_01_Shatin', 'NEW_SELECTION', "ALIAS_ENAM = 'Roadabout'")

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.