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?
1 Answer 1
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)
-
That was exactly itPitrako Junior– Pitrako Junior2018年04月19日 15:32:32 +00:00Commented Apr 19, 2018 at 15:32