1

I am trying to build a simple query where a feature layer field needs to be smaller than a certain number and another feature layer field needs to be bigger than a variable previously created in the script.

I know the following query (comparing a feature layer field with 2 strings) works fine.

> query = "ESTATE LIKE '{0}' OR ESTATE LIKE '{1}'".format('Node Live%','Node%Planned%')

So, I thought the following line would be correct:

> query = "gridcode < '{0}' AND Shape_Area > '{1}'".format(2,thres_area)

But it seems it isn't

NOTE: 'gridcode' and 'Shape_Area' are two feature layer fields and 'thres_area' is a script variable (integer) previously created.

Any idea what would the correct sintaxis be like?

2

You are querying a number but the value is treated like a string (because of the single quotes). Try

query = "gridcode < {0} AND Shape_Area > {1}".format(2,thres_area)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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