Select to view content in your preferred language

IBasicGeoprocessor error

1020
1
Jump to solution
05-15-2012 10:27 PM
UsmanJamil2
Emerging Contributor
Hello Every one, i am using the code below to find the intersection of two layers.  I'm getting an error (screen shot attached here with) while executing the GP tool. can any one help me with it of what this error is about??


            IMap pMap = axMapControl1.Map;
            ILayer pLayer1 = pMap.get_Layer(0);
            IFeatureLayer pFeatureLayer1 = (IFeatureLayer)pLayer1;
            IFeatureClass pFeatureClass1 = pFeatureLayer1.FeatureClass;

            ILayer pLayer2 = pMap.get_Layer(1);
            IFeatureLayer pFeatureLayer2 = (IFeatureLayer)pLayer2;
            IFeatureClass pFeatureClass2 = pFeatureLayer2.FeatureClass;

            IWorkspaceName pNewWSName;
            IFeatureClassName pFeatClassName;
            IDatasetName pDatasetName;
            pFeatClassName = new FeatureClassNameClass();
            pDatasetName = (IDatasetName)pFeatClassName;
            pNewWSName = new WorkspaceNameClass();
            pNewWSName.WorkspaceFactoryProgID = "esriCore.ShapeFileWorkspaceFactory";
            pNewWSName.PathName = "D:\\Usman";
            pDatasetName.WorkspaceName = pNewWSName;
            pDatasetName.Name = "Intersect_result";
            //pFeatClassName.FeatureType = esriFeatureType.esriFTSimple;
            //pFeatClassName.ShapeType = esriGeometryType.esriGeometryAny;
            //pFeatClassName.ShapeFieldName = "Shape";

            IBasicGeoprocessor pBGP;
            IGeoProcessor pGP;
            double tol = 0;
            IFeatureClass pOutputFC;
            pBGP = new BasicGeoprocessorClass();

            pOutputFC = pBGP.Intersect(pFeatureClass1 as ITable, false, pFeatureClass2 as ITable, false, tol, pFeatClassName);

Best Regards,

Usman Jamil
0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor
Usman,

I don't program in c# so may be what you have done in standard but this line looks odd to me:

pOutputFC = pBGP.Intersect(pFeatureClass1 as ITable, false, pFeatureClass2 as ITable, false, tol, pFeatClassName); 

I would not have done the query interface in the method call. In VB I would have done this:

dim pT1 as ITable dim pT2 as ITable pT1 = pFeatureClass1 pT2 = pFeatureClass2 pOutputFC = pBGP.Intersect(pT1, false, pT2, false, tol, pFeatClassName)


Also its worth noting that in the Help it says:

"The functionality of the BasicGeoprocessor object had been superseded by the new Geoprocessing framework of ArcGIS starting at version 9.0. Developers should utilize the new tools whenever possible."

So they are saying don't use it.

Duncan

View solution in original post

0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor
Usman,

I don't program in c# so may be what you have done in standard but this line looks odd to me:

pOutputFC = pBGP.Intersect(pFeatureClass1 as ITable, false, pFeatureClass2 as ITable, false, tol, pFeatClassName); 

I would not have done the query interface in the method call. In VB I would have done this:

dim pT1 as ITable dim pT2 as ITable pT1 = pFeatureClass1 pT2 = pFeatureClass2 pOutputFC = pBGP.Intersect(pT1, false, pT2, false, tol, pFeatClassName)


Also its worth noting that in the Help it says:

"The functionality of the BasicGeoprocessor object had been superseded by the new Geoprocessing framework of ArcGIS starting at version 9.0. Developers should utilize the new tools whenever possible."

So they are saying don't use it.

Duncan
0 Kudos