1

I have a vector layer containing all of the property parcels in the county. There is a field called "PROP_TYPE" that contains the type of property. I am trying to select all of the residential properties, which are coded as "RES" in the PROP_TYPE field.

I tried to do this by clearing current selection, making sure the parcels layer was the active layer, and then going to the "Select features by expression" dialog, and typed in the following queries:

"PROP_TYPE" IS "RES"

"PROP_TYPE" LIKE "%RES%"

The first returns only 533 features, but there are approximately 75,000 of them that should be selected. I can count them when sorted by prop_type in the attributes table, and see that they all contain exactly the same text in this field ("RES") ... so I can't figure out why some are matching and others aren't. Also, I don't understand why the first result would return 533 while the second would return 0. I would think the 2nd one would always have at least as many as the first, if not more, since the pattern includes more possible matches.

Can someone explain to me what is going on?

5

Use double quotation marks for field names. Use single quotation marks for strings. In your example,

"PROP_TYPE" IS "RES"

You're asking QGIS to select features whose value in the "PROP_TYPE" field is the same as their value in the "RES" field.

In order to select features whose value in the "PROP_TYPE" field is the string value 'RES', use this expression:

"PROP_TYPE" IS 'RES'

EDIT: A missing field reference will evaluate to null, so if you don't have a field called "RES", your expression becomes "PROP_TYPE" IS NULL. This selection expression will select all features with null values in the "PROP_TYPE" field. The second expression will be "PROP_TYPE" LIKE NULL.. which is never true, hence no selection. -Thanks to @ndawson for providing this explanation.

  • Ah that was it :) Thanks! I'm curious why "PROP_TYPE" IS "RES" turned up anything, given that there is no RES field? There are two fields called RES_QUAL and RES_COND ... would it require both of these to be the same as PROP_TYPE, just one of them, or is something else happening? – J. Taylor Mar 9 '18 at 21:42
  • 3
    I suspect you have some null values in PROP_TYPE. A missing field reference will evaluate to null, so your expression becomes "PROP_TYPE" IS NULL. The second expression will be "PROP_TYPE" LIKE NULL.. which is never true, hence no selection. – ndawson Mar 9 '18 at 23:01

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.