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?

asked Apr 19, 2018 at 15:13

1 Answer 1

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)
answered Apr 19, 2018 at 15:20
1
  • That was exactly it Commented Apr 19, 2018 at 15:32

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.