I want to clip the features based on selected polygon.I have the two layers "suburban" and "lot". I want to clip features of lot layer based on selected polygon from suburban layer. I have tried manually in arc map 10.3 using Analaysis tools->Extract->Clip. It clipped lot features only which are underlying on selected polygons of suburban layer. But it's not working correctly when trying the same from ArcObjects .Net using geoprocessor interface.
It's not clipping the lot feature based on selected polygon of suburban layer.Instead of clipping the lot features based on all the polygon of the suburban layer.
Expected output:
I am also tried ITopologicalOperator QueryClipped functionality.It clip the features only in rectangular (envelop) size.It's not exactly clip the features based on irregular polygon boundary.
I am using the following code.
Private Sub lotClip(ByVal pInFClass As ESRI.ArcGIS.Geodatabase.IFeatureClass, ByVal clipGeometry As IGeometry, ByVal pClipFClass As ESRI.ArcGIS.Geodatabase.IFeatureClass, ByVal outputName As String)
Dim clipperGeo As New ESRI.ArcGIS.AnalysisTools.Clip
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Try
Using releaser As New ESRI.ArcGIS.ADF.ComReleaser
releaser.ManageLifetime(clipperGeo)
clipperGeo.in_features = pInFClass
clipperGeo.clip_features = clipGeometry
clipperGeo.out_feature_class = outputName
Result = runClipTool(clipperGeo, Nothing)
If Result Is Nothing Then
System.Windows.Forms.MessageBox.Show("Could not clip dataset")
Exit Sub
End If
ReturnObjectfromResult(Result, "Feature Class")
End Using
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "Clip error")
End Try
End Sub
Friend Function runClipTool(ByVal Process As ESRI.ArcGIS.Geoprocessor.IGPProcess, ByVal TC As ESRI.ArcGIS.esriSystem.ITrackCancel2) As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
Try
Result = CType(GP.Execute(Process, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)
If Result.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then returnMessages(Result, "Geoprocessing Error")
GP.ClearMessages()
Catch ex As Exception
returnMessages(Result, "Fail")
System.Windows.Forms.MessageBox.Show(ex.ToString, "Run Geoprocessor")
End Try
Return Result
End Function
Friend Sub ReturnObjectfromResult(ByVal result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2, ByVal Type As String)
Dim GPVal As ESRI.ArcGIS.Geodatabase.IGPValue
Dim InMemFC As String
Dim GPUtil As ESRI.ArcGIS.Geoprocessing.IGPUtilities3 = New ESRI.ArcGIS.Geoprocessing.GPUtilities
Dim pOutputFc As ESRI.ArcGIS.Geodatabase.IFeatureClass
Try
GPVal = result.GetOutput(0)
InMemFC = GPVal.GetAsText()
Select Case Type
Case "Feature Class"
pOutputFc = GPUtil.OpenFeatureClassFromString(InMemFC)
Case "Table"
GPUtil.OpenTableFromString(InMemFC)
End Select
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "Return FeatureClass error")
End Try
End Sub
How do I clip the features based on an irregular polygon?