Select to view content in your preferred language

Convex hull

2922
5
01-12-2012 04:05 AM
DissDiss
Emerging Contributor
Hello everybody,

I try to create a convex hull of points with java and arcobjects - therefore I like to use the tool Minimum bounding rectangle from the Data Management Toolbox. The points are within the point shapefile test.shp.

I tried it like that:

                GeoProcessor GP = new GeoProcessor();
                MinimumBoundingGeometry mbg = new MinimumBoundingGeometry();
  mbg.setInFeatures("d:/test.shp");
  mbg.setGeometryType("convex_hull");
  mbg.setOutFeatureClass("d:/output.shp");
  GP.execute(mbg, null);

Unfortunately, it doesn't work. Does anybody know what to do?

Thanks for any help!
0 Kudos
5 Replies
DuncanHornby
MVP Notable Contributor
If you look at the help on this geoprocessing tool it says:

The CONVEX_HULL, CIRCLE, and ENVELOPE options are only available with an ArcInfo license.


Are you using ArcInfo?
0 Kudos
DissDiss
Emerging Contributor
Thanks for your reply. Yes, I'm using ArcInfo Licence.
0 Kudos
DuncanHornby
MVP Notable Contributor
Diss,

I created a VB AddIN and in the onclick event I put this code together and got it working. It looks like the input layer has to be a featurelayer object and not a string.

Duncan


        ' Get handle input point layer
        Dim pmap As IMap
        pmap = My.ArcMap.Document.FocusMap
        Dim pLayer As ILayer
        pLayer = pmap.Layer(0)
        Dim pFeatureLayer As IFeatureLayer
        pFeatureLayer = pLayer
       
        ' Run geoprocessing tool
        Try
            ' Create Minimum bounding geometry tool
            Dim mbg = New ESRI.ArcGIS.DataManagementTools.MinimumBoundingGeometry()
            With mbg
                .geometry_type = "convex_hull"
                .in_features = pFeatureLayer
                .out_feature_class = "c:\temp\conhull.shp"
            End With

            ' Cast as a GPProcess
            Dim pGPProcess As ESRI.ArcGIS.Geoprocessor.IGPProcess
            pGPProcess = mbg

            ' Create GeoProcessor
            Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
            GP.OverwriteOutput = True
            GP.AddOutputsToMap = True

            ' Execute tool
            Dim pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
            pResult = GP.Execute(pGPProcess, Nothing)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        MsgBox("finished!")
0 Kudos
DissDiss
Emerging Contributor
Hello,

Thanks for your help Hornbydd. Sorry for my late reply - I couldnt been here for a long time.

Now I tried it like that:

public void convexhull(ILayer merge)
{
GeoProcessor GP = new GeoProcessor();
  IFeatureLayer featureLayer = (IFeatureLayer)merge;
  MinimumBoundingGeometry mbg = new MinimumBoundingGeometry();
  mbg.setInFeatures(featureLayer);
  mbg.setGeometryType("convex_hull");
  mbg.setOutFeatureClass("C:/output.shp");
  GP.execute(mbg, null);

...
}

but now I'm getting an Automation expression error in the line with "GP.execute(mbg, null)". Any idea due to what this error can occur?

Thanks for any help!
0 Kudos
ravenjam
New Contributor
just use ITopologicalOperator,u'll be fine
0 Kudos