Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

i have to make an intersection between a polygon and a layer of parcels, the polygon used in the clip is not belonging to any layer and the result of this intersection should be all the parcels inside and cuted by the polygon (clip) so i thought to use ITopologicalOperator but i haven't understood how to work with this tool , also it seems to give one feature as result but in my case i need a set of features.

can you give me the right tool to use in Arcobject for my case ?

any advice is welcome :)

thanks in advance

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Create a spatial filter (ISpatialFilter) with the geometry and get a featurecursor for the layer (using IFeatureclass.Search). Cast the search geometry to ITopologicalOperator and call Intersect on each IFeature.Shape returned by IFeatureCursor.Next().

share|improve this answer
    
thanks for your help , i was very useful :) , but i'm still stuck with creating new layer in arc objects , i have tried this code it do not work i have a bug in the line with # –  geogeek Sep 10 '11 at 11:46
add comment

thanks for your help , it was very useful :) , but i'm still stuck with creating new layer where i could put the result of the intersection, i have tried this code but it do not work i have a bug in the line with #

code

'''''''''''''''''''''''''''''''''''' Set pSpatialFilter = New SpatialFilter Set pSpatialFilter.Geometry = pPoly 'the polygone clip pSpatialFilter.SpatialRel = esriSpatialRelContains Set pUpdateCursor = fcpu.Update(pSpatialFilter, False) Set pTopOp = pPoly Set pFeature = pUpdateCursor.NextFeature

Dim geom As IGeometry Dim fe As IFeature

' get the workspace and start editing

Dim fcout As IFeatureClass Dim pNewWSName As IWorkspaceName Dim pFeatClassName As IFeatureClassName Dim pDatasetName As IDatasetName Set pFeatClassName = New FeatureClassName Set pDatasetName = pFeatClassName

Set pNewWSName = New WorkspaceName pNewWSName.WorkspaceFactoryProgID = _ "esriCore.ShapeFileWorkspaceFactory" pNewWSName.PathName = "c:\" Set pDatasetName.WorkspaceName = pNewWSName pDatasetName.Name = "Intersect_result"

Dim pFName As IName Set pFName = pFeatClassName

Set fcout = pFName.Open # ' here it stops Dim pDataset As IDataset Set pDataset = fcout

Dim pWorkspace As IWorkspace Set pWorkspace = pDataset.Workspace

Dim pWorkspaceEdit As IWorkspaceEdit Set pWorkspaceEdit = pWorkspace

pWorkspaceEdit.StartEditing True pWorkspaceEdit.StartEditOperation

'''''''''''''''

Dim pFeat As IFeature Dim pRow As IRow Dim pFlds As IFields Dim lSFld As Long Dim i As Long

Do Until pFeature Is Nothing

'Set fe = New Feature

'Set geom = pTopOp.Intersect(pFeature.Shape, esriGeometry1Dimension)

Set pFeat = fcout.CreateFeature 'fcout.Fields = pFeat.Fields

' Set pFlds = pFeat.Fields ' For i = 0 To pFlds.FieldCount - 1

' lSFld = pFeature.Fields.FindField(pFlds.Field(i).Name)

'    pFeat.Value(i) = pFeature.Value(lSFld)

' Next i

Set pFeat.Shape = pTopOp.Intersect(pFeature.Shape, esriGeometry1Dimension) pFeat.Store Set pFeature = pUpdateCursor.NextFeature Loop pWorkspaceEdit.StopEditOperation pWorkspaceEdit.StopEditing True

share|improve this answer
    
Please edit the question and add the code there, instead of answering your own question with a new question. –  MathiasWestin Sep 12 '11 at 14:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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