Click or drag to resize

ArcGISFeature Class

Represents a Feature stored in an ArcGISFeatureTable.
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.Data
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class ArcGISFeature : Feature, 
	ILoadable

The ArcGISFeature type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleAttributes
Gets the attributes of this GeoElement as a collection of name/value pairs.
(Inherited from GeoElement.)
Public propertyCanEditAttachments
Gets a value indicating whether attachments on this feature can be edited.
Public propertyCanUpdateGeometry
Gets a value indicating whether geometry on this feature can be edited.
Public propertyCode exampleFeatureTable
Gets the FeatureTable that this feature belongs to
(Inherited from Feature.)
Public propertyGeometry
Gets or sets the Geometry of the feature.
(Inherited from Feature.)
Public propertyLoadError
Gets the load status of feature.
Public propertyLoadStatus
Gets the load status of feature.
Top
Methods
  NameDescription
Public methodAddAttachmentAsync
Asynchronously adds a new attachment to this feature.
Public methodCancelLoad
Cancels an ongoing load.
Public methodCode exampleDeleteAttachmentAsync
Asynchronously deletes the specified attachment from this feature.
Public methodDeleteAttachmentsAsync
Asynchronously deletes the specified attachment from this feature.
Public methodCode exampleGetAttachmentsAsync
Asynchronously retrieves a collection of Attachment associated with this feature.
Public methodGetAttributeValue(String)
Looks up attribute by name and returns its current value.
(Inherited from Feature.)
Public methodGetAttributeValue(Field)
Looks up attribute by Field and returns its current value.
(Inherited from Feature.)
Public methodGetFeatureSubtype
Gets the corresponding FeatureSubtype for this feature.
Public methodCode exampleLoadAsync
Initiates loading of feature.
Public methodCode exampleRefresh
Resets the attributes and geometry to the values in the data source
(Inherited from Feature.)
Public methodRefreshObjectId Obsolete.
Updates both the object ID and global ID (if applicable) of this feature to get the permanent values after the edits have been applied to the service with ApplyEditsAsync.
Public methodRelateFeature(ArcGISFeature)
Sets up a relationship between this feature and the provided feature.
Public methodRelateFeature(ArcGISFeature, RelationshipInfo)
Sets up a relationship between this feature and the provided feature based on the given relationshipInfo.
Public methodRetryLoadAsync
Retry loading feature.
Public methodSetAttributeValue(String, Object)
Looks up attribute by name and updates attribute to the specified value.
(Inherited from Feature.)
Public methodSetAttributeValue(Field, Object)
Looks up attribute by Field and updates attribute to the specified value.
(Inherited from Feature.)
Public methodUnrelateFeature
Removes the relationship between this feature and the provided feature.
Public methodUpdateAttachmentAsync
Asynchronously updates the specified Attachment of this feature.
Top
Events
  NameDescription
Public eventLoaded
Occurs when feature is loaded.
Public eventLoadStatusChanged
Occurs feature's LoadStatus is changed.
Top
Remarks

An ArcGISFeature can contain:

  • A set of attributes that describe the real-world entity it represents.
  • A geometry that defines its location and shape. The geometry might contain m-values, which are typically used for linear referencing.
  • Zero or more feature attachments such as images or documents.
A feature's attribute values can be changed, but attribute definitions cannot be added, deleted, or modified.

If you create a ServiceFeatureTable from the URL of a feature service, features in the table are initially in one of the following states:

  • A minimum set of attributes are available in the table, and m-values are omitted. This is an optimization for faster rendering.
  • All attributes defined by the service are available in the table, including m-values, which might be NaN.
The initial state of features is determined by the feature request mode of the table. For important details, see FeatureRequestMode.

By default, a query on ArcGISFeatures in a minimum state will return them in the same state. To access all attributes (or the m-values) of features returned by a query, you must load the features. You can do one of the following:

For more information, see the class description for ServiceFeatureTable.

Examples

UWP

Example Name: AddFeatures

Add features to a feature layer.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using Windows.UI.Popups;

namespace ArcGISRuntime.UWP.Samples.AddFeatures
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Add features",
        category: "Data",
        description: "Add features to a feature layer.",
        instructions: "Click on a location on the map to add a feature at that location.",
        tags: new[] { "edit", "feature", "online service" })]
    public partial class AddFeatures
    {
        // URL to the feature service.
        private const string FeatureServiceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0";

        // Hold a reference to the feature table.
        private ServiceFeatureTable _damageFeatureTable;

        public AddFeatures()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Create the map with streets basemap.
            MyMapView.Map = new Map(BasemapStyle.ArcGISStreets);

            // Create the feature table, referring to the Damage Assessment feature service.
            _damageFeatureTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl));

            // Create a feature layer to visualize the features in the table.
            FeatureLayer damageLayer = new FeatureLayer(_damageFeatureTable);

            // Add the layer to the map.
            MyMapView.Map.OperationalLayers.Add(damageLayer);

            // Listen for user taps on the map - this will select the feature.
            MyMapView.GeoViewTapped += MapView_Tapped;

            // Zoom to the United States.
            MyMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7);
        }

        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // Create the feature.
                ArcGISFeature feature = (ArcGISFeature) _damageFeatureTable.CreateFeature();

                // Get the normalized geometry for the tapped location and use it as the feature's geometry.
                MapPoint tappedPoint = (MapPoint) GeometryEngine.NormalizeCentralMeridian(e.Location);
                feature.Geometry = tappedPoint;

                // Set feature attributes.
                feature.SetAttributeValue("typdamage", "Minor");
                feature.SetAttributeValue("primcause", "Earthquake");

                // Add the feature to the table.
                await _damageFeatureTable.AddFeatureAsync(feature);

                // Apply the edits to the service.
                await _damageFeatureTable.ApplyEditsAsync();

                // Update the feature to get the updated objectid - a temporary ID is used before the feature is added.
                feature.Refresh();

                // Confirm feature addition.
                await new MessageDialog($"Created feature {feature.Attributes["objectid"]}", "Success!").ShowAsync();
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString(), "Error adding feature").ShowAsync();
            }
        }
    }
}
XAML
<UserControl 
    x:Class="ArcGISRuntime.UWP.Samples.AddFeatures.AddFeatures"
    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}">
            <TextBlock Text="Tap to add features."
                       TextAlignment="Center"
                       FontWeight="SemiBold" />
        </Border>
    </Grid>
</UserControl>
Examples

Xamarin Forms UWP

Example Name: AddFeatures

Add features to a feature layer.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using System;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using Xamarin.Forms;

namespace ArcGISRuntimeXamarin.Samples.AddFeatures
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Add features",
        category: "Data",
        description: "Add features to a feature layer.",
        instructions: "Tap on a location on the map to add a feature at that location.",
        tags: new[] { "edit", "feature", "online service" })]
    public partial class AddFeatures : ContentPage
    {
        // URL to the feature service.
        private const string FeatureServiceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0";

        // Hold a reference to the feature table.
        private ServiceFeatureTable _damageFeatureTable;

        public AddFeatures()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Create the map with streets basemap.
            MyMapView.Map = new Map(BasemapStyle.ArcGISStreets);

            // Create the feature table, referring to the Damage Assessment feature service.
            _damageFeatureTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl));

            // Create a feature layer to visualize the features in the table.
            FeatureLayer damageLayer = new FeatureLayer(_damageFeatureTable);

            // Add the layer to the map.
            MyMapView.Map.OperationalLayers.Add(damageLayer);

            // Listen for user taps on the map - this will select the feature.
            MyMapView.GeoViewTapped += MapView_Tapped;

            // Zoom to the United States.
            MyMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7);
        }

        private async void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            try
            {
                // Create the feature.
                ArcGISFeature feature = (ArcGISFeature) _damageFeatureTable.CreateFeature();

                // Get the normalized geometry for the tapped location and use it as the feature's geometry.
                MapPoint tappedPoint = (MapPoint) GeometryEngine.NormalizeCentralMeridian(e.Location);
                feature.Geometry = tappedPoint;

                // Set feature attributes.
                feature.SetAttributeValue("typdamage", "Minor");
                feature.SetAttributeValue("primcause", "Earthquake");

                // Add the feature to the table.
                await _damageFeatureTable.AddFeatureAsync(feature);

                // Apply the edits to the service.
                await _damageFeatureTable.ApplyEditsAsync();

                // Update the feature to get the updated objectid - a temporary ID is used before the feature is added.
                feature.Refresh();

                // Confirm feature addition.
                await Application.Current.MainPage.DisplayAlert("Success!", $"Created feature {feature.Attributes["objectid"]}", "OK");
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error adding feature", ex.ToString(), "OK");
            }
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime" 
             x:Class="ArcGISRuntimeXamarin.Samples.AddFeatures.AddFeatures">
  <Grid>
    <esriUI:MapView x:Name="MyMapView"/>
  </Grid>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddFeaturesAdd features to a feature layer.
EditBranchVersioningCreate, query and edit a specific server version using service geodatabase.
EditFeatureAttachmentsAdd, delete, and download attachments for features from a service.
ListRelatedFeaturesList features related to the selected feature.
MapImageLayerTablesFind features in a spatial table related to features in a non-spatial table.
PerformValveIsolationTraceRun a filtered trace to locate operable features that will isolate an area from the flow of network resources.
TraceUtilityNetworkDiscover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.
UpdateAttributesUpdate feature attributes in an online feature service.
UpdateGeometriesUpdate a feature's location in an online feature service.