Hi All,
I have been trying using IBasicGeoprocessor interface's Intersect method, to create point layer at the point of intersection between the 2 layers.(one is line layer & other is polygon layer)
But even after setting outputFeatureClass's shapeType property to esriGeometryPoint, type of output layer is Polygon.
Could you please help me in resolving this issue.
Thanking you in advance.
Regards,
Viji
Code I used is as below:
Option Explicit
Public Sub Intersect()
' Get the input layer and feature class
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pLayer As ILayer
Set pLayer = pMxDoc.FocusMap.Layer(1)
Dim pInputFeatLayer As IFeatureLayer
Set pInputFeatLayer = pLayer
' Use the Itable interface from the Layer (not from the FeatureClass)
Dim pInputTable As ITable
Set pInputTable = pLayer
' Get the input feature class.
' The Input feature class properties, such as shape type,
' will be needed for the output
Dim pInputFeatClass As IFeatureClass
Set pInputFeatClass = pInputFeatLayer.FeatureClass
' Get the overlay layer
' Use the Itable interface from the Layer (not from the FeatureClass)
Set pLayer = pMxDoc.FocusMap.Layer(0)
Dim pOverlayTable As ITable
Set pOverlayTable = pLayer
' Error checking
If pInputTable Is Nothing Then
MsgBox "Table QI failed"
Exit Sub
End If
If pOverlayTable Is Nothing Then
MsgBox "Table QI failed"
Exit Sub
End If
' Dim pFLayer_Ref As IFeatureLayer
' Set pFLayer_Ref = pMxDoc.FocusMap.Layer(2)
' Define the output feature class name and shape type (taken from the
' properties of the input feature class)
Dim pFeatClassName As IFeatureClassName
Set pFeatClassName = New FeatureClassName
With pFeatClassName
.FeatureType = esriFTSimple
.ShapeFieldName = "Shape"
.ShapeType = esriGeometryPoint
End With
pFeatClassName.ShapeType = esriGeometryPoint
pFeatClassName.FeatureType = esriFTSimple
' Set output location and feature class name
Dim pNewWSName As IWorkspaceName
Set pNewWSName = New WorkspaceName
pNewWSName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapeFileWorkspaceFactory.1"
pNewWSName.PathName = "C:\temp"
Dim pDatasetName As IDatasetName
Set pDatasetName = pFeatClassName
pDatasetName.Name = "Intersect_result1"
Set pDatasetName.WorkspaceName = pNewWSName
' Set the tolerance. Passing 0.0 causes the default tolerance to be used.
' The default tolerance is 1/10,000 of the extent of the data frame's spatial domain
Dim tol As Double
tol = 0# ' Perform the intersect
Dim pBGP As IBasicGeoprocessor
Set pBGP = New BasicGeoprocessor
Dim pOutputFeatClass As IFeatureClass
Set pOutputFeatClass = pBGP.Intersect(pInputTable, False, pOverlayTable, False, _
tol, pFeatClassName)
' Add the output layer to the map
Dim pOutputFeatLayer As IFeatureLayer
Set pOutputFeatLayer = New FeatureLayer
Set pOutputFeatLayer.FeatureClass = pOutputFeatClass
pOutputFeatLayer.Name = pOutputFeatClass.AliasName
pMxDoc.FocusMap.AddLayer pOutputFeatLayer
End Sub