ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / Modify Method / Modify(Layer,Int64,Geometry,Dictionary<String,Object>) Method
The layer of the feature to modify.
The oid of the feature to modify.
The geometry to update on the feature.
(Optional). The attribute values to update on the feature (by field Name).
Example

In This Topic
    Modify(Layer,Int64,Geometry,Dictionary<String,Object>) Method
    In This Topic
    Modify a feature, updating the geometry and attribute values.
    Syntax
    Public Overloads Sub Modify( _
       ByVal layer As Layer, _
       ByVal oid As Long, _
       ByVal geometry As Geometry, _
       Optional ByVal attributes As Dictionary(Of String,Object) _
    ) 

    Parameters

    layer
    The layer of the feature to modify.
    oid
    The oid of the feature to modify.
    geometry
    The geometry to update on the feature.
    attributes
    (Optional). The attribute values to update on the feature (by field Name).
    Example
    Edit Operation Modify single feature
    var modifyFeature = new EditOperation() { Name = "Modify a feature" };
    
    //use an inspector
    var modifyInspector = new Inspector();
    modifyInspector.Load(featureLayer, oid);//base attributes on an existing feature
    
    //change attributes for the new feature
    modifyInspector["SHAPE"] = polygon;//Update the geometry
    modifyInspector["NAME"] = "Updated name";//Update attribute(s)
    
    modifyFeature.Modify(modifyInspector);
    
    //update geometry and attributes using overload
    var featureAttributes = new Dictionary<string, object>();
    featureAttributes["NAME"] = "Updated name";//Update attribute(s)
    modifyFeature.Modify(featureLayer, oid, polygon, featureAttributes);
    
    //Execute to execute the operation
    //Must be called within QueuedTask.Run
    if (!modifyFeature.IsEmpty)
    {
      var result = modifyFeature.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
    }
    
    //or use async flavor
    //await modifyFeatures.ExecuteAsync();
    
    Move feature to a specific coordinate
    //Get all of the selected ObjectIDs from the layer.
    var abLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
    var mySelection = abLayer.GetSelection();
    var selOid = mySelection.GetObjectIDs().FirstOrDefault();
    
    var moveToPoint = new MapPointBuilderEx(1.0, 2.0, 3.0, 4.0, MapView.Active.Map.SpatialReference); //can pass in coordinates.
    
    var modifyFeatureCoord = new EditOperation() { Name = "Move features" };
    modifyFeatureCoord.Modify(abLayer, selOid, moveToPoint.ToGeometry());  //Modify the feature to the new geometry 
    if (!modifyFeatureCoord.IsEmpty)
    {
      var result = modifyFeatureCoord.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
    }
    
    Update Annotation Text via attribute. Caveat: The TEXTSTRING Anno attribute must exist
    //See "Change Annotation Text Graphic" for an alternative if TEXTSTRING is missing from the schema
    await QueuedTask.Run(() =>
    {
        //annoLayer is ~your~ Annotation layer...
    
        // use the inspector methodology
        var insp = new Inspector();
        insp.Load(annoLayer, oid);
    
        // make sure TextString attribute exists.
        //It is not guaranteed to be in the schema
        ArcGIS.Desktop.Editing.Attributes.Attribute att = insp.FirstOrDefault(a => a.FieldName == "TEXTSTRING");
        if (att != null)
        {
            insp["TEXTSTRING"] = "Hello World";
    
            //create and execute the edit operation
            EditOperation op = new EditOperation();
            op.Name = "Update annotation";
            op.Modify(insp);
    
            //OR using a Dictionary - again TEXTSTRING has to exist in the schema
            //Dictionary<string, object> newAtts = new Dictionary<string, object>();
            //newAtts.Add("TEXTSTRING", "hello world");
            //op.Modify(annoLayer, oid, newAtts);
    
            op.Execute();
        }
    });
    Edit the attributes of a FeatureSceneLayer
    //must support editing!
    var featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                       .OfType<FeatureSceneLayer>().FirstOrDefault();
    if (!featSceneLayer.HasAssociatedFeatureService || 
        !featSceneLayer.IsEditable)
      return;
    
    var ok = await QueuedTask.Run(() =>
    {
      var editOp = new EditOperation()
      {
        Name = "Edit FeatureSceneLayer Attributes",
        SelectModifiedFeatures = true
      };
      //make an inspector
      var inspector = new Inspector();
      //get the attributes for the specified oid
      inspector.Load(featSceneLayer, oid);
      inspector["PermitNotes"] = "test";//modify
      editOp.Modify(inspector);
      return editOp.Execute();//synchronous flavor
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also