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)
1
  • 1
    We use a Question/Answer model. Please don't place the answer in the Question.
    – Vince
    Sep 14 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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.