The Find by Attributes and Location tool performs spatial and attribute queries to find features or parts of features that meet the specified criteria.
Operators
Find by Attributes and Location uses operators for attribute and spatial queries.
Attribute operators
There are several operators that you can use for an attribute query, depending on whether the field you are querying is categorical or numerical.
If your field is a string, you can use the following operators:
- is—Strings that match the specified text.
- is not—Strings that do not match the specified text.
- starts with—Strings that begin with the specified text.
- ends with—Strings that finish with the specified text.
- contains—Strings that have the provided text.
- does not contain—Strings that don't have the provided text.
- is blank—Strings that have no text, and are not null.
- is not blank—Strings that have some text, and are not null.
- is empty—Strings that are null or have no text.
- is not empty—Strings that have some text, or are null.
If your field is numerical, you can use the following operators:
- is—Numbers that match the specified value.
- is not—Numbers that do not match the specified value.
- is at least—Numbers that are equal to or greater than the specified value.
- is less than—Numbers that are less than the specified value.
- is at most—Numbers that are less than or equal to the specified value.
- is greater than—Numbers that are greater than the specified value.
- is between—Numbers that are between the two specified values.
- is not between—Numbers that are not between the two specified values.
- is blank—Numbers that match the specified value.
- is not blank—Numbers that have some value.
If your field is a date, you can use the following operators:
- is between—Dates that are between two specified dates.
- is not between—Dates that are not between two specified dates.
- is on—Dates that are the same as a specified date.
- is not on—Dates that are not the same as a specified date.
- is before—Dates that are before a specified date.
- is after—Dates that are after a specified date.
- is blank—Dates that are null.
- is not blank—Dates that are not null.
Spatial operators
Spatial expressions are created by specifying operators such as completely within or intersects.
You can use the following spatial operator in a spatial query:
- Intersects—If a feature in the first layer intersects a feature in the second layer, the feature in the first layer is included in the output.
- Does not intersect—If a feature in the first layer intersects a feature in the second layer, the feature in the first layer is excluded from the output.
- Within a distance of—A feature in the first layer is selected (included in the output) if any part is within the specified distance of a feature in the second layer; for example, parcels within 100 meters of a river will be included in the output.
- Not within a distance of—A feature in the first layer is excluded (not included in the output) if it is within a distance of another feature; for example, parcels within 100 meters of a river will not be included in the output. You can think of this relationship as the feature is farther away than the specified distance.
- Completely contains—If a feature in the first layer completely contains a feature in the second layer, the feature in the first layer is included in the output.
- Does not completely contain—If a feature in the first layer completely contains a feature in the second layer, the feature in the first layer is excluded from the output.
- Comletely within—If a feature in the first layer is completely within a feature in the second layer, the feature in the first layer is included in the output.
- Not completely within—If a feature in the first layer is completely within a feature in the second layer, the feature in the first layer is excluded from the output.
- Nearest to—If a feature in the first layer is nearest to a feature in the second layer, the feature in the first layer is included in the output.
Query builder
To build a query, click the Build new query button.
To start, pick the layer you'd like to find features from. Next, pick if you'd like to start with an attribute expression or a spatial expression. Each attribute query includes a field name, an operator, and a value. Each spatial expression includes an operator and a second layer. Below the second layer, you can use the +Expression button to add an expression to further refine the features from the second layer that will be used in the original spatial expression.
For example, you can create a query on a layer containing a city's crime incident data (thefts, arson fires, assaults, and so on) to show only theft incidents. Create an attribute expression as follows:
- For the field name, choose Crime Type.
- For the operator, choose is.
- For the value, write Theft.
With another layer representing donut shops, you can further refine the query to look for thefts that occurred within 100 meters of a donut shop. Add a spatial expression, as follows:
- For the operator, choose Within a distance of and enter 100 meters.
- For the layer, choose the donut shop layer.
If the query has more than one expression, you must choose a matching option to connect the expressions. In the example above, the All of the following are true option is selected. This means that only the features that match all of the expressions—in this case, thefts within 100 meters of a donut shop—are returned when the expression is applied.
Other queries may require the One of the following are true option. For example, to show all thefts, and any crime within 100 meters of a donut shop, choose One of the following are true.
Expression group
To create a more complex query, you can use expression groups to group multiple expressions. The way in which you group the expressions determines what you are finding. You can create up to three levels of grouping.
For example, you can use expression groups to further refine the crime incident filter described above. To show both arson fire and theft incidents reported within a distance of 100 meters of a donut shop, you can create an expression group to find arson fires or theft incidents. Within that group use the One of the following are true option. Then, outside of the group, add a spatial expression for finding features within 100 meters.