I have a set of point features and I wish to find the points that have common coordinates. Now I changed the code as shwon bewlo by using the IPoint and the compare method through a function. I have 2 loops with cursors. The first one should read the first point while the second loop the second point etc. How can I force the cursor of the second loop to go to the second point? I addedd another NextFeature but it did not work.The result is that all the points are the same between the 2 loops.
Thanks
Demetris
Set pFeature = pFCursor.NextFeature
Do Until pFeature Is Nothing
Set pPointA = pFeature.Shape
Set pFeature2 = pFCursor2.NextFeature
Do Until pFeature2 Is Nothing
'Set pFeature2 = pFCursor2.NextFeature
Set pPointB = pFeature2.Shape
CommonPoints = ComparePoints(pPointA, pPointB)
If CommonPoints = True Then
MsgBox "Yes"
End If
Set pFeature2 = pFCursor2.NextFeature
Loop
Function ComparePoints(pointA As IPoint, pointB As IPoint) As Boolean
If pointA.Compare(pointB) Then
ComparePoints = True
Else
ComparePoints = False
End If
End Function
Best Answer
Okay, based on the additional information in the comments, I am proposing another way to go about reaching the actual goal which is identifying the coincident points in a point feature class. I will now perform this feat with zero programming (cue Europe's "The Final Countdown").
SHAPE
field since we are only interested in comparing the geometry. Enter appropriate XY and Z tolerances or accept the defaults. This will produce a standalone table containing a record for each feature in the input feature class, with columns for each feature's original ObjectID (IN_FID
), and a sequential value (FEAT_SEQ
) that will be the same for all features that were determined to be identical.FEAT_SEQ
field as the frequency field. This will create another standalone table with the a field containing the count of the number of times each sequential value occured.OBJECTID
field in the points layer andFID
field in the table.FEAT_SEQ
field in the joined Find Identical table, and theFEAT_SEQ
field in the Frequency table.FREQUENCY
> 1. Congratulations, you have now identified all the coincident points! Now do something with them.Tips: You might use the in-memory workspace (
"in_memory\someData"
) for the two stand-alone tables since they are only needed temporarily and the number of features is small. You could also script this easily with Python!