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 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
share|improve this question
    
In addition to my answer below, I noticed that you're not setting a variable called "pFCursor2", but are trying to call "pFCursor2.NextFeature". –  Nick Ochoski Oct 17 '11 at 17:00
    
@Demetris - on which line does it crash? –  Jakub Oct 17 '11 at 17:22
    
Also, If GetX(pFeature)= GetX(pFeature2) Then will always evaluate to true (0 = 0) since you are not setting the GetX function to a value. You might need to replace the last line in the GetX function with GetX = Round(pPoint.x, 2). As for the error itself, we might need to see how you set both cursors and exactly which line raises the error. –  Jakub Oct 17 '11 at 17:31
    
Also, do not use recycling cursors when storing references to the features. That is, the second parameter to IFeatureClass.Search should be False instead of True. –  Petr Krebs Oct 17 '11 at 18:05
    
I added above all the code before creating the array. I also changed the pFCursor2 and usued the same pFCursor. While I had to get a result given the IF-THEN condition I added in the loop (that is the Msgbox), the program run now without stopping but without also giving a right result.What do you think? –  Demetris Oct 17 '11 at 18:06
show 5 more comments

2 Answers

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").

  1. In ArcMap, add the point feature class in question as a layer.
  2. Use Find Identical (Data Management) on the feature layer containing the coincident points. Select the 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.
  3. Use Frequency (Analysis) on the resulting Find Identical table. Select the 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.
  4. Join the Find Identical table to the point feature layer on the OBJECTID field in the points layer and FID field in the table.
  5. Join the Frequency table to the point feature layer on the FEAT_SEQ field in the joined Find Identical table, and the FEAT_SEQ field in the Frequency table.
  6. Select by Attributes on the point feature layer all those records where 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!

share|improve this answer
1  
+1 Great solution that is fairly versatile for other applications. –  Nick Ochoski Oct 18 '11 at 15:21
add comment

If you're using points you might consider implementing IPointCollection instead of an array. You can use the built in methods to accomplish what you're asking and it should be a bit more efficient since you won't require an external method to get your IPoint.

Your steps would be:

1) Add each feature (point) to the IPointCollection using ".Add".

2) Compare yourPoint.X and/or yourPoint.Y.

share|improve this answer
    
Could you give me some more details please? –  Demetris Oct 17 '11 at 16:35
    
I've added a couple simple steps to my answer. What you essentially want to do is add each point to the collection(think of it like a custom array for handling points). Once you have all your points in the collection you can loop over each one using a cursor and compare the coordinate values using point.X and/or point.Y. –  Nick Ochoski Oct 17 '11 at 16:38
    
Here is an AddPoint example in VBA - edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriGeometry/… –  Nick Ochoski Oct 17 '11 at 16:40
    
The first step is clear. Regarding the second I cannot understand how can I compare the X,Y of the point that the cursor is with all the other points of the dataset (i.e. the first point with the rest points, the secod point with the rest points etc.). Could you explain me please? –  Demetris Oct 17 '11 at 17:00
    
IPoint has a .Compare method than can be adapted to sort or match points. Aside from there are a number of ways to handle this comparison, but it will come down to programming preference since it's not specifically related to GIS - what you're asking is "how can I compare one item in a collection to all other items in the collection". The collection type (IPointCollection, array) doesn't really matter for this step, it just simplifies your storage of the data (in this case, points). –  Nick Ochoski Oct 17 '11 at 17:10
show 5 more comments

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.