0

I'm trying to make a simple script tool that allows the user to search a for a specific polygon in a feature class using a unique number.

Using the python window in ArcGisPro I run arcpy.management.SelectLayerByAttribute setting the where clause to state_parcel_id = '840723200011000007' and the tool works, selects the appropriate polygon, and I get message saying <Result 'Parcel Boundaries of Indiana With DLGF Tables 2022\Parcel_Boundaries'>

However when I try replace 840723200011000007 with param0 and run it, I only get the same message back of

<Result 'Parcel Boundaries of Indiana With DLGF Tables 2022\Parcel_Boundaries'>

It doesn't select anything or doesn't give any errors. I've search around the web and tried to play around with it but no luck.

This doesn't select anything and doesn't give an error:

param0 = 840723200011000007
arcpy.management.SelectLayerByAttribute(
 r"Parcel Boundaries of Indiana With DLGF Tables 2022\Parcel_Boundaries", 
 "NEW_SELECTION", 
 "state_parcel_id = 'param0'", 
 None)

This selects the right polygon:

arcpy.management.SelectLayerByAttribute(
 r"Parcel Boundaries of Indiana With DLGF Tables 2022\Parcel_Boundaries", 
 "NEW_SELECTION", 
 "state_parcel_id = '840723200011000007'", 
 None)
Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Sep 14, 2023 at 13:22
1
  • 1
    We use a Question/Answer model. Please don't place the answer in the Question. Commented Sep 14, 2023 at 15:39

1 Answer 1

2

Check that you're formatting your parameter into the selection string correctly. I'd guess looking at this that your query ends up looking for a parcel who's id are the string "param0" instead of the value stored by the variable param0.

Trying updating your parcel id selection line to:

"state_parcel_id = '{param0}'".format(param0=param0)
answered Sep 14, 2023 at 13:27

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.