1

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?

asked Feb 3, 2015 at 16:18

1 Answer 1

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);
answered Feb 3, 2015 at 16:43
2
  • 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? Commented Feb 3, 2015 at 17:37
  • Intersection of lines.shp and polygon.shp is stored in output.shp. Commented Feb 4, 2015 at 0:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.