Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a shapefile with a column of type esriFieldTypeOID with the name FID and numbers from 0 to 5 (the first odd think is that ArcMap does not show a * next to the column name in the table view even if its of the OID type)

After duplicating the whole FeatureClass I have my FID column in the new FeatureClass but this time I have the numbers from 1 to 6!

If I use another file were I have the number from 1 to 6 I have also 1 to 6 in the copy. According to the doc the OID is an integer and not null, therefore the 0 to 5 should not be a problem.

Thats the code I use:

// get FeatureClassName for input
        IDataset inDataset = inFeatureClass as IDataset;
        IFeatureClassName inFeatureClassName = inDataset.FullName as IFeatureClassName;
        IWorkspace inWorkspace = inDataset.Workspace;

        // get WorkSpaceName for output
        IDataset outDataset = outWorkspace as IDataset;
        IWorkspaceName outWorkspaceName = outDataset.FullName as IWorkspaceName;

        // Create new FeatureClassName
        IFeatureClassName outFeatureClassName = new FeatureClassNameClass();
        // Assign it a name and a workspace
        IDatasetName datasetName = outFeatureClassName as IDatasetName;
        datasetName.Name = newName == String.Empty ? (inFeatureClassName as IDatasetName).Name : newName;
        datasetName.WorkspaceName = outWorkspaceName;

        // Check for field conflicts.
        IFieldChecker fieldChecker = new FieldCheckerClass();
        IFields inFields = inFeatureClass.Fields;
        IFields outFields;
        IEnumFieldError enumFieldError;
        fieldChecker.InputWorkspace = inWorkspace;
        fieldChecker.ValidateWorkspace = outWorkspace;
        fieldChecker.Validate(inFields, out enumFieldError, out outFields);
        // Check enumFieldError for field naming confilcts

        //Convert the data.
        IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();
        featureDataConverter.ConvertFeatureClass(inFeatureClassName, null, null,
        outFeatureClassName, null, outFields, "", 100, 0);

        IFeatureWorkspace pFeatureWS = (IFeatureWorkspace)outWorkspace;
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

After hours of searching I found the solution ESRI knowledge base.

When a geodatabase feature class is exported or converted to a new geodatabase feature class, or when a geodatabase table is exported or converted to a new geodatabase table, the records are renumbered sequentially starting at 1 in the output feature class or table.

And they also described the problem of this behavior.

It is important to be aware of these behaviors when selecting fields for joining or relating tables. If a shapefile were to be joined to a feature class using the FID and OBJECTID fields, the shapefile record with FID = 0 would not be matched to a record in the feature class, as there is no record in a feature class with OBJECTID = 0.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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