In ArcGIS Runtime SDKs, features and graphics represent real-world objects on a map. Every feature and graphic has a geometry representing its shape and location, as well as other attributes that further describe the represented object. For example, polygon features could represent land parcels and include attributes about each one such as parcel ID or owner. Point graphics could represent event locations, including the event's time and type. When displayed on a map, features and graphics may be rendered using a variety of symbols.
Features and graphics are similar to one another in that they both have a geometry and attributes, this is represented by the geo-element interface which they both implement. However, features are designed for different uses than graphics. Your choice between using a graphic or a feature depends on various factors, such as whether they are persisted in a data store or a map, whether they all share a single geometry type and set of attributes, or how your app displays them. This topic describes and compares features and graphics and helps you choose which is best to use in various cases.
The following table compares important characteristics of features and graphics:
Comparison of features and graphics
In a feature layer in a map in a map view.
In a graphics overlay in a map view.
In a feature table in a data store (such as a database or service) or in a map.
In app memory only.
Geometry type (point, line, and so on)
Features of different geometry types cannot exist in the same layer.
Graphics of different geometry types can exist in the same graphic overlay.
Features in the same data store or feature layer have a common attribute schema.
Each graphic may have a set of attributes unlike other graphics in the same graphic overlay.
Symbolized according to the renderer defined for the feature service or the feature layer.
If persisted in a feature collection table in a map, the renderer can be overridden with feature-specific symbols.
Symbolized individually or according to the graphics overlay’s renderer.
Via the map view.
Via the map view.
Created, updated and deleted using feature table operations
Created through a graphic constructor and added to the graphics overlay graphics collection. Attributes and geometry updated by reference on a graphic instance
How features and graphics relate to a map
A map contains layers, among other things. Feature layers in a map are used to display features, feature layers are bound to a feature table. Features are not displayed using a graphics overlay.
A map view contains a map and graphic overlays, among other things. Graphic overlays in a map view are used to display graphics on top of the map and any layers the map contains. Graphics are not displayed using layers.
Where do features come from?
Features can be hosted in an online service, stored locally in a database, saved in a map or saved as a portal item. How you access features in your app affects how you make and manage edits to them.
A feature service provides online access to features and can be hosted by ArcGIS Enterprise or ArcGIS Online. A feature service contains one or several collections of features. If you visit the REST Services Directory page for a feature service, you'll see the collections of features it contains listed under the Layers heading, as shown in the following image. Features of different geometry types (point, line, and polygon, in other words) cannot exist in the same collection, so it's common to see features organized according to geometry type in addition to theme.
The feature service in the example contains several datasets, including three that describe C2 Military Operations using points, lines, and areas (polygons). The number in parenthesis indicates the index position inside the feature service. To access a specific set of features, append the index position to the URL for the service. Hostile Units, for example, can be accessed at https://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/FeatureServer/6.
Features in your ArcGIS Runtime app are stored in feature tables of which there are many types. Features that come directly from a feature service are stored in a service feature table, which is created using the URL for the service and index position (see the URL above). Features read from a local geodatabase are stored in a geodatabase feature table, for more information on how to create a geodatabase see Create an offline layer. Static features stored in a map or portal item are stored in a feature collection table as part of a feature collection.
Since a feature service or local geodatabase can contain several sets of features (tables, in other words), you may need to create many feature tables in your ArcGIS Runtime app to represent all the datasets you need.
Types of features
Different feature table types return different feature objects. Feature tables that inherit directly from the FeatureTable base class return the Feature object type. Feature tables which inherit from ArcGISFeatureTable have additional capabilities such as attachments, these return ArcGISFeature objects.
For increased efficiency, the ArcGISFeature object implements the loadable pattern. When fetching features for rendering and query purposes, a minimum set of required fields are returned, such as identifiers, geometry, fields used for symbolizing, and so on. When you need all of the available fields you can simply load the feature.
When querying features, you have the option to return your results as loaded features so all fields are immediately available.
It's not necessary to display the features you work with in your app. If you want your user to view (and interact with) features on a map, however, add the feature table that contains them as a feature layer. A feature layer can display features from any type of feature table. See the layers and tables topic for more information about creating and working with feature layers.
Features in a feature layer can use different request modes, including caching of features, for efficient display on the client. You should be aware of the various feature request modes, as the caching behavior of feature layers may affect the editing experience. Feature request modes are described in detail in the layers and tables topic.
A feature layer can also display data from a map service or a geodatabase in a mobile map package, in which case the data in the underlying feature table will be read-only.
Where do graphics come from?
Graphics are created by the developer and added to the application. They can be created from results from various operations such as querying, identifying, geoprocessing, geocoding or routing. They can also be created from external data sources, but if you want to persist the data in a map then you must use features. Graphics can also be created by the developer as a result of a map click or touch.
When to use features
Persistence is a built-in characteristic of features. Features are persisted in a data store such as a database, a service, a map or a portal item. When this data store is available to multiple apps and users, a common set of data is available to all. Sharing data among users is a common use case for features.
Compare this to graphics, which reside in the memory of a single running app session. Graphics are created by the app during the session and are available only during that session.
You can publish features as part of a feature service. Layers in a feature service can be displayed in a map, symbolized in various ways, and queried using attribute, spatial, or temporal criteria. The editing workflows and tools available in ArcGIS Runtime SDK also make it possible to expose editing functionality in your app. You can even add code to control the type of edits made and who gets to make them.
The following example adds a new feature layer to the map based on an online data source. The symbology (renderer) used to display the layer is defined with the feature service.
// define an online data source (ServiceFeatureTable)
var uri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0");
var incidentsFeatureTable = new ServiceFeatureTable(uri);
// await loading of the table then check the load status
if(incidentsFeatureTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
// create a new feature layer, pass the service feature table to the constructor
var incidentsLayer = new Esri.ArcGISRuntime.Mapping.FeatureLayer(incidentsFeatureTable);
// add the feature layer to the map
When to use graphics
Apps create graphics as needed, and graphics do not need to be persisted. Therefore, graphics are ideal for displaying things that are specific to the session, or anything that is displayed only temporarily. For example, the results of some tasks are returned as graphics, which your app may display on a graphics overlay.
The following are some common uses for graphics:
- Display text on top of a map
- Highlight a section of the map by overlaying a polygon graphic
- Display results from spatial analysis, such as buffer polygons created around features
- Display a route between two locations
- Display geometry drawn interactively by the app user
- Animate data items that change quickly, such as moving objects
The following example adds a provided polyline geometry as a graphic to a graphics overlay in the map view. The symbol for the graphic is created and applied explicitly.
private void DrawLineGraphic(Polyline polylineShape)
// get the first graphics overlay in the map view
var myGraphics = MyMapView.GraphicsOverlays;
// define a line symbol (dashed blue)
var lineSymbol = new SimpleLineSymbol();
lineSymbol.Color = Colors.Blue;
lineSymbol.Style = SimpleLineSymbolStyle.Dash;
lineSymbol.Width = 2;
// create a new graphic; set the Geometry and Symbol
var lineGraphic = new Esri.ArcGISRuntime.UI.Graphic();
lineGraphic.Geometry = polylineShape;
lineGraphic.Symbol = lineSymbol;
// add the graphic to the graphics overlay