I can promatically Clipping but CAN'T Erase, please help me. (ArcEngine with VB.net)

09-26-2010 06:19 AM
New Contributor
Dear helpers.
I would like to built an application with Erase and Clip (I use ArcEngine with Vb.net). I try some code and my code can CLip but can not Erase, I don't know why.
Would you please help me to correct code and explain me why?
Thank you very much for helping.

Following are my codes. (I have attached data files)


Imports System.IO
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.output
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.Geodatabase
'Imports ESRI.ArcGIS.Geoprocessing
Imports ESRI.ArcGIS.Geoprocessor
Imports ESRI.ArcGIS.AnalysisTools

Public Class MainForm
   Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Dim ClipTool As ESRI.ArcGIS.AnalysisTools.Clip = New ESRI.ArcGIS.AnalysisTools.Clip()
        ClipTool.in_features = "E:\Temp\Road.shp"   'axMapControl1.Map.Layer(0) 
        ClipTool.clip_features = "E:\Temp\Boundary.shp"     'axMapControl1.Map.Layer(1)
        ClipTool.out_feature_class = "E:\Temp\clip_out.shp"

        Dim gp_clip As Geoprocessor = New Geoprocessor
        Dim resultsClip As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult = CType(gp_clip.Execute(ClipTool, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)

       '''''=>> ResultsCLip is a   System.___Object


        Dim EraseTool As ESRI.ArcGIS.AnalysisTools.Erase = New ESRI.ArcGIS.AnalysisTools.Erase
        EraseTool.in_features = "E:\Temp\Road.shp"                ' axMapControl1.Map.Layer(0)
        EraseTool.erase_features = "E:\Temp\Boundary.shp"     'axMapControl1.Map.Layer(1)
        EraseTool.out_feature_class = "E:\Temp\Erase_out.shp"
        Dim gp_Erase As Geoprocessor = New Geoprocessor
        Dim resultsErase As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult = CType(gp_Erase.Execute(EraseTool, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)

      '''''=>> ResultsErase is Nothing....Please why???

   End Sub
End Class
Ngo T
GIS for Sustainable Development,
Hanoi, Vietnam
0 Kudos
4 Replies
Occasional Contributor II
The Erase tool needs an ArcInfo license. May be you are using an editor or viewer license?
0 Kudos
New Contributor
Thank you very much for your guide.

My computer (the computer I use to build program) is installed ArcGIS Desktop Arcinfo and ArcInfo Workstation also. And I also tried using erase tool (ArcToolbox) in Arcmap and it work without any problems.
Do you think that my code is not contain any logic error? I will try to find error from my license.

Thank you.
0 Kudos
New Contributor
Still don't know why, please...pls help me... 😞 :mad:
0 Kudos
New Contributor
Could any one check if my code work successful in your computer?
0 Kudos