Feature layer query

View inMAUIUWPWPFWinUIView on GitHub

Find features in a feature table which match an SQL query.

Image of feature layer query

Use case

Query expressions can be used in ArcGIS to select a subset of features from a feature table. This is most useful in large or complicated data sets. A possible use case might be on a feature table marking the location of street furniture through a city. A user may wish to query by a TYPE column to return "benches". In this sample, we query a U.S. state by STATE_NAME from a feature table containing all U.S. states.

How to use the sample

Input the name of a U.S. state into the text field. When you click the button, a query is performed and the matching features are highlighted or an error is returned.

How it works

  1. Create a ServiceFeatureTable using the URL of a feature service.
  2. Create a QueryParameters with a where clause specified using the WhereClause property.
  3. Perform the query using QueryFeaturesAsync(query) on the service feature table.
  4. When complete, the query will return a FeatureQueryResult which can be iterated over to get the matching features.

Relevant API

  • FeatureLayer
  • FeatureQueryResult
  • QueryParameters
  • ServiceFeatureTable

About the data

This sample uses U.S. State polygon features from the USA 2016 Daytime Population feature service.

Tags

search, query

Sample Code

FeatureLayerQuery.xamlFeatureLayerQuery.xamlFeatureLayerQuery.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<UserControl
    x:Class="ArcGIS.UWP.Samples.FeatureLayerQuery.FeatureLayerQuery"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock Text="Enter a state name and press 🔎 to search."
                           TextAlignment="Center" FontWeight="SemiBold"
                           IsColorFontEnabled="False"
                           Margin="0,0,0,5" />
                <AutoSuggestBox Text="New York"
                                QueryIcon="Find"
                                HorizontalAlignment="Stretch"
                                QuerySubmitted="QueryEntry_QuerySubmitted" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close