i am trying to pass polyline and polygon feature classes i am not sure how to pass the list of features to the Intersect object:
i tried this method:
ArrayList<Object> featuresList = new ArrayList<>();
FeatureClass polygonfeatureClass = openFeatureClassFromShapeFile(srcShapefilePath, "polygon.shp");
FeatureClass polylinefeatureClass = openFeatureClassFromShapeFile(srcShapefilePath, "lines.shp");
Intersect newintersect = new Intersect();
featuresList.add(polylinefeatureClass);
featuresList.add(polygonfeatureClass);
gp = new GeoProcessor();
gp.setOverwriteOutput(true);
gp.setTemporaryMapLayers(false);
gp.setAddOutputsToMap(false);
gp.setEnvironmentValue("workspace", srcShapefilePath);
newintersect.setInFeatures(featuresList)
i get this error :
Item not found in this collection. in 'DAO.Fields'
com.esri.arcgis.geoprocessing.GeoProcessor.execute(Unknown Source)
i tried to pass the shape files pathes as string too> i got the same error then i tried this method: after i created 2 feature classes in gdb
String in1=srcShapefilePath + File.separator + "layers.gdb" + File.separator + "lines";
String in2=srcShapefilePath + File.separator + "layers.gdb" + File.separator + "polygon";
newintersect.setInFeatures(in1 + ";" + in2);
gp.execute(newintersect, null);
and i got the same error
AutomationException: 0x80004005 - Unspecified error at com.esri.arcgis.geoprocessing.GeoProcessor.execute(Unknown Source) at com.esri.arcgis.geoprocessing.GeoProcessor.execute(Unknown Source)
Any Idea?
1 Answer 1
@mashhour-darweish ,Try the below approach.The code is in C# style. It may be similar in Java too.
Geoprocessor GP = new Geoprocessor();
GP.OverwriteOutput = true;
Intersect IntersectDataset = new Intersect();
IntersectDataset.in_features = "(" + srcShapefilePath+"\\polygon.shp", "polygon.shp" + "; " + srcShapefilePath+"\\lines.shp" + ")";
IntersectDataset.out_feature_class = srcShapefilePath+"\\myoutput.shp";
IntersectDataset.output_type = "LINE";
IGeoProcessorResult result;
result = (IGeoProcessorResult)GP.Execute(process, null);
-
i used the same way in your code @Durga an there is no error: String in = "(" + srcShapefilePath + "\\polygon.shp; " + srcShapefilePath + "\\lines.shp)"; that what java accepts. but what the output.shp , is it an empty shape file which i have created already?mashhour darweish– mashhour darweish2015年02月03日 17:37:03 +00:00Commented Feb 3, 2015 at 17:37
-
Intersection of lines.shp and polygon.shp is stored in output.shp.addcolor– addcolor2015年02月04日 00:59:13 +00:00Commented Feb 4, 2015 at 0:59