ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / BasicFeatureLayer Class / GetFeatureOutline Method
The viewer on which the layer's features are being displayed
The type of outline to generate (from which features)
Example

In This Topic
    GetFeatureOutline Method
    In This Topic
    Get an outline geometry created from the geometries of the set of input features. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public Geometry GetFeatureOutline( 
       MapView view,
       FeatureOutlineType outlineType
    )
    Public Function GetFeatureOutline( _
       ByVal view As MapView, _
       ByVal outlineType As FeatureOutlineType _
    ) As Geometry

    Parameters

    view
    The viewer on which the layer's features are being displayed
    outlineType
    The type of outline to generate (from which features)

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    MapView is null
    Unsupported geometry type
    Feature outline failed.
    Remarks
    The view must be initialized or null will be returned. The layer must be set visible in the view (i.e. visibility turned "on"). The outline geometry will be created from all the features, just the selected features, or just the features visible within the current view extent (FeatureOutlineType.All, Selected, or Visible respectively). The feature outline geometry is returned in the spatial reference of the input mapview's associated Map
    Note: A null geometry can be returned, for example, FeatureOutlineType.Selected and no features are selected, FeatureOutlineType.Visible and no features are visible within the current view extent, and so on.
    Feature layers with Multipatch geometry type are not supported.
    Example
    Querying a feature layer with a spatial filter
              // Note: Run within QueuedTask.Run
              // Set the spatial filter geometry
    
              //Get the geometry from the selected features in the feature layer
              var spatialClauseGeom = spatialDefnLayer.GetFeatureOutline(MapView.Active, FeatureOutlineType.Selected);
    
    DefinitionQuery definitionQuery = new DefinitionQuery
    {
      WhereClause = whereClause,
      Name = $"{layerToQuery.Name}"
    };
    //Setting the spatial filter to the Definition Query
    if (definitionQuery.CanSetFilterGeometry(spatialClauseGeom))
    {
      definitionQuery.SetFilterGeometry(spatialClauseGeom);
    }
    
    layerToQuery.InsertDefinitionQuery(definitionQuery);
    layerToQuery.SetActiveDefinitionQuery(definitionQuery.Name);
    Apply A Definition Query Filter With a Filter Geometry to a Feature Layer
        var greatLakes = map.GetLayersAsFlattenedList()
                    .OfType<FeatureLayer>().First(l => l.Name == "Great Lakes");
        var usa_states = map.GetLayersAsFlattenedList()
        .OfType<FeatureLayer>().First(l => l.Name == "US_States");
    
        QueuedTask.Run(() =>
        {
    //name must be unique
            var def_query = new DefinitionQuery("GreatLakes",
                                                        "NAME in ('Huron','Michigan','Erie')");
    
            //create a filter geometry - in this example we will use the outline geometry
            //of all visible features from a us states layer...the filter geometry will be
    //intersected with the layer feature geometry when added to the def query
            var filter_geom = usa_states.GetFeatureOutline(mv, FeatureOutlineType.Visible);
            //other options...
            //var filter_geom = usa_states.GetFeatureOutline(mv, FeatureOutlineType.All);
            //var filter_geom = usa_states.GetFeatureOutline(mv, FeatureOutlineType.Selected);
    
            //Geometry must have a valid SR and be point, multi-point, line, or poly
            if (def_query.CanSetFilterGeometry(filter_geom))
    {
      def_query.SetFilterGeometry(filter_geom);
    }
    
            //Apply the def query
            greatLakes.InsertDefinitionQuery(def_query);
            //Set it active
            greatLakes.SetActiveDefinitionQuery(def_query.Name);
    
            //or....also - set it active when it is inserted
            //greatLakes.InsertDefinitionQuery(def_query, true);
        });
    Get Feature Outlines from a Feature Layer
          var greatLakes = map.GetLayersAsFlattenedList()
                      .OfType<FeatureLayer>().First(l => l.Name == "Great Lakes");
    var michigan = map.GetBookmarks().First(b => b.Name == "Michigan");
    
          QueuedTask.Run(() =>
          {
    
              //get all features - multiple feature geometries are always returned as a
      //single multi-part
              var all_features_outline = greatLakes.GetFeatureOutline(mv, FeatureOutlineType.All);
    
      //or get just the outline of selected features
      var qry = new QueryFilter()
      {
        SubFields = "*",
        WhereClause = "NAME in ('Huron','Michigan','Erie')"
      };
      greatLakes.Select(qry);
              var sel_features_outline = greatLakes.GetFeatureOutline(
          mv, FeatureOutlineType.Selected);
      greatLakes.ClearSelection();
    
              //or just the visible features
              mv.ZoomTo(michigan);
              var visible_features_outline = greatLakes.GetFeatureOutline(
                      mv, FeatureOutlineType.Visible);
          });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also