Help with IBasicGeoprocessor.Merge

222
1
05-21-2012 08:54 AM
DerekLoi
New Contributor III
I have managed to merge all the layers (with the same table attributes) into one single shapefile.  However, the table structure is not the same as the original.  For instance, my layers in the map control have fields named "Contact", "Address", "Location", "Phone" and the merged shapefile has a table with fields: "field_1", "field_2", "field_3", etc
Worse, there isn't even any data in any of the fields...
What am I doing wrong?

            ITable inputTable = null;                        
            // Create a feature class name for the output shapefile and open the output's workspace
            IWorkspaceName pWorkspaceName = new WorkspaceNameClass();
            pWorkspaceName.WorkspaceFactoryProgID = "esriCore.ShapeFileWorkspaceFactory.1";
            pWorkspaceName.PathName = @"C:\Temp";

            // define the temp output featureclass name
            IFeatureClassName pFeatClassName = new FeatureClassNameClass();
            pFeatClassName.FeatureType = esriFeatureType.esriFTSimple;
            pFeatClassName.ShapeFieldName = "Shape";
            pFeatClassName.ShapeType = esriGeometryType.esriGeometryPolygon;
            IDatasetName pDatasetName = (IDatasetName)pFeatClassName;
            pDatasetName.Name = "Merge_Result"; 
            pDatasetName.WorkspaceName = pWorkspaceName;

            IArray featArray = new ArrayClass();
            ILayer pLayer;
            for (int i = 0; i < axMapControl1.LayerCount; i++)
            {
                pLayer = (ILayer)axMapControl1.get_Layer(i);          
                inputTable = (ITable)pLayer;
                featArray.Add(inputTable);
            }

            // perform the merge
            IBasicGeoprocessor pBGP = new BasicGeoprocessorClass();
            try
            {
                IFeatureClass pOutFeatureClass = pBGP.Merge(featArray, inputTable, pFeatClassName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
0 Kudos
1 Reply
DerekLoi
New Contributor III
ok I think I know why my field names are changing... the original featureclasses (that are being merged) have field names that are longer than 8 characters and dbf flat files only support up to 8 character field names....  so is it possible to rename the ITable fields to something shorter?
0 Kudos