Describing data (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Using geoprocessing > Accessing a dataset > Describing data (ArcObjects .NET 10.6 SDK)

Describing data

Working with data

Geoprocessing tools work with all types of data, such as geodatabase feature classes, shapefiles, rasters, tables, topologies, and networks. Each piece of data has properties that can be used to control the flow of a program or the parameters of a tool. For example, the output feature type of an intersect operation is dependent on the type of data being intersected. When the Intersect tool is run in a program on a list of input datasets, it must be able to determine the data types used so the correct output type can be set.
Using the geoprocessor's GetDataElement method, a dataset's properties can be determined and used to make decisions. GetDataElement returns an IDataElement object that can be used to describe the given value. All data element classes support the IDataElement interface. Refer to IDataElement for a list of all the data element classes that implement IDataElement. See the following code example:
public void ExampleGPGetDatasetProperties(Geoprocessor GP)

    // Describe the input feature class.
    object dtype="";
    IDataElement dataelement=GP.GetDataElement(@"C:\GP\PortlandOR.gdb\streets",
        ref dtype);

    // Open the feature class data element and get the shape type.
    IDEFeatureClass defc=dataelement as IDEFeatureClass;

    if (defc.FeatureType == esriFeatureType.esriFTSimple)
        Console.WriteLine("Feature type is simple.");

    if (defc.ShapeType == esriGeometryType.esriGeometryPolyline)
        Console.WriteLine("ShapeType is polyline.");

    if (defc.ShapeFieldName="Shape")
        Console.WriteLine("Shape field name is Shape.");

Public Sub ExampleGPGetDatasetProperties(ByVal GP As Geoprocessor)
    ' Describe the input feature class.
    Dim dtype As Object=""
    Dim dataelement As IDataElement=GP.GetDataElement("C:\GP\PortlandOR.gdb\streets", dtype)
    ' Open the feature class data element and get the shape type.
    Dim defc As IDEFeatureClass=TryCast(dataelement, IDEFeatureClass)
    If (defc.FeatureType=esriFeatureType.esriFTSimple) Then
        Console.WriteLine("Feature type is simple.")
    End If
    If (defc.ShapeType=esriGeometryType.esriGeometryPolyline) Then
        Console.WriteLine("ShapeType is polyline.")
    End If
    If (defc.ShapeFieldName="Shape") Then
        Console.WriteLine("Shape field name is Shape.")
    End If
End Sub

To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):