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?

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 Feb 3 '15 at 17:37
  • Intersection of lines.shp and polygon.shp is stored in output.shp. – addcolor Feb 4 '15 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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