A filter presents a focused view of a feature layer in a map. Limiting the visibility of features in a layer helps to reveal the important aspects of the layer. For example, if you have a layer showing shark attacks, you can create a filter to show the areas with the most attacks. By showing patterns of the most attacks in an area, you can help your city to warn future beachgoers about potential attacks.
Access existing filters
Any changes you make only apply to your view of the map.
- Click the Filter button on any layer in the Compilation window layer list.
Add filters to your layer.
- Modify or remove the filter.
- On the View tab, you can view the filter on the layer and remove it as well.
- On the Edit tab, you can edit the expressions.
Create filters
You can create filters on hosted feature layers, ArcGIS Server feature service layers, and ArcGIS Server map service layers that have associated attribute data. Only the features that meet the expression criteria appear in the Compilation window.
Hinweis:
Layers added from the following file formats do not support filters: CSV, TXT, GPX, and shapefile.
- Open the Compilation window.
- Click Add Content.
- Select Add Layers.
- Browse to the feature layer you want to filter and add it to the Compilation window.
- Click Filter .
- Create your definition expression.
- Expressions use the general form of <Field_name> <Operator> <Value, Field, or Unique>.
- You can create one expression, multiple expressions, or one or more sets of expressions. A set is a grouping of expressions, for example, Type is elementary and Enrollment is at least 400.
- If you have more than one expression, choose to display features in the layer that match All or Any of your expressions. All requires that all of the criteria you have specified must be true. Any means that only one of your expressions must be true for the features to display.
- For the field part of the expression, click the Field drop-down arrow and choose the field you want to query against.
Hinweis:
If the layer has several fields, you can type a search term in the box to reduce the list of field names.
You'll see field aliases instead of the field names from the data if the layer has field aliases defined.
- For the operator part of the expression, click the Operators drop-down arrow and choose an operator.
- To filter based on a specific value, choose Value and enter a value in the field. The input box varies depending on the field type.
- To compare the value in one field with the value in another field, choose Field, click the drop-down arrow, and choose the field for your expression. To filter based on a specific value in the field you've selected for your expression, choose Unique and select a unique value from your field. Unique value filters require a 10.1 or later map service layer. The Unique option does not appear if you are creating a filter on a 10.0 or earlier service layer.
- To delete an expression in the filter, click the Delete button to the right of your expression.
- Click Apply Filter to enable the filtered view on the map.
- To undo the filter and show all the features in the layer, click Remove Filter.
Filter by date
You can filter some feature layers by date. For example, you may want to show the locations of earthquakes that occurred during a specified date range.
Using the in the last and not in the last operators, you can also apply a dynamic date filter to a hosted feature layer to show events that occurred relative to the current day—for example, all features that were edited in the last five days—without having to manually update the filter each day. Other available operators for date filters include is on, is not on, is before, is after, is between, is not between, and so on.
- In the Compilation window, add data with date fields.
- Click Filter .
- Create your definition expression for the date filter as follows:
- Select a date field from the Field drop-down menu.
- Select an operator from the Operator drop-down menu.
Hinweis:
The in the last and not in the last operators are only available for hosted feature layers.
- Do one of the following, depending on how you want to filter the data:
- To filter based on a specific date value, click Value and enter a value. Depending on the operator you select, you can specify a single date (or two dates) from the calendar; enter one or two dates manually; or specify a time range in days, weeks, or months.
- To compare the value in one field with the value in another field, click Field and select a field from the drop-down menu. To filter based on a specific value in the date field you selected for your expression, click Unique and select a unique date value.
Considerations
Keep the following in mind when you're working with filters:
- You can create filters on hosted feature layers, hosted feature layer views, ArcGIS Server feature service layers, and ArcGIS Server map service layers that have associated attribute data.
Hinweis:
Filters applied to hosted feature layers and hosted feature layer views do not restrict access to the layer's data. Anyone with access to the layer can remove the filter and access the data.
- Do not add special characters to your values unless those special characters are part of the value. For example, City is "New York" doesn't find a feature named New York. In this example, use City is New York instead.
- If your field includes coded values, the Values list shows all coded values defined by the service for the field. This may include values that do not exist as features in the layer. The Unique list shows all the features in the layer (which may be a subset of the values in the service). The Unique option requires a 10.1 or later map service layer. This option does not appear if you are filtering a 10.0 or earlier map service layer. If you have multiple expressions, your results will vary depending on how and if you group them in sets. For example, if you create a filter where all of the following expressions must be true, Type is middle or Type is secondary (this is a set) and Category is private (this is a single expression), the filter selects private middle schools and private secondary schools. If you instead create your filter where the following must be true, Type is secondary and Category is private (now this is your set) or Type is middle (this is a single expression), the filter selects all public and private middle schools and private secondary schools.