2

I'm writing an ArcGIS 10.1 .pyt toolbox to accept a feature class as input (not a shapefile). Referencing ESRI's online guide to 'Geoprocessing Data Types of Parameters and Environments' [PDF warning], I can set the datatype to either 'DEFeatureClass' or 'IFeatureClass'. What's the difference between these two datatypes? Which should I use and why?

Example code from the getParameterInfo method:

treePolys = arcpy.Parameter(
    displayName = "Input tree polygons feature class:",
    name = "tpolys",
    datatype = "DEFeatureClass", 
    parameterType = "Required",
    direction = "Input")
  • 1
    Do you really care about the explanation? I started writing one but it really only makes sense for ArcObjects developers and otherwise is a nuance that really doesn't matter to arcpy programmers (just do what it says in the help topic I linked). – blah238 Aug 27 '13 at 17:55
  • Your answer was just what I needed, but I'm also curious as to what IFeatureClass is for? – Axel Esteban Aug 27 '13 at 17:57
  • 1
    Where does it say that IFeatureClass is a valid datatype value for a parameter in a Python toolbox? That is the name of an ArcObjects CoClass, not a string for a Parameter datatype. While the list of strings is similar to the list of class names you can use, it's not the same. Please use the documentation @blah238 refers to as your reference. – Jason Scheirer Aug 27 '13 at 18:40
2

According to the help topic "Defining parameter data types in a Python toolbox", you should use "DEFeatureClass".

1

What is the difference between DEFeatureClass and IFeatureClass?

First a short explanation of Interface vs. Implementation: DEFeatureClass is a CoClass ID, meaning it is an implementation of IDEFeatureClass. In COM, interfaces are separated from implementations. To get a DEFeatureClass, you must first declare an instance of IDEFeatureClass and use that to get DEFeatureClass.

Now, onto what the DEFeatureClass is: The DEFeatureClass is the data element for your feature class. A data element is the metadata for the feature class. It contains only read/write properties that describe the feature class with no methods. It's purpose is to store and retrieve information about the feature class. Notice that you can change various properties describing your feature class from here as all of the properties are read/write.

An IFeatureClass is used to control the behavior of the feature class. It does things with the feature class versus simply storing information about the feature class. Notice in the documentation that this object includes various methods that you can execute on the feature class, such as DeleteIndex, DeleteField, FeatureCount, etc. However, it also contains information about the feature class, albeit in read-only (get) format. Notice in the link that properties describing the feature class, such as FeatureType, are all read-only.

Which should you use, and why?

See comments below. You must use DEFeatureClass. The link you provided in .pdf describes the different data types that correspond to the feature class. The only one that is relevant to you is the DEFeatureClass.

  • 1
    You fail to acknowledge that DEFeatureClass is a CoClass ID and IFeatureClass is an Interface. An object must implement IGPDataType in order for it to be a valid data type in a Python toolbox. IFeatureClass is not a valid value for a datatype in an arcpy Parameter object. – Jason Scheirer Aug 27 '13 at 18:44
  • @JasonScheirer Looks good, I will edit my answer. – Conor Aug 27 '13 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.