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 work in GIS with VBA. I have 2 Points layer.One of them is City points and another is hydro station points.I want write code in vba for selecting one point from station layer and finding closest city to this selected point.On the other hand I should find nearest point to a selected point. Please help me.

share|improve this question
3  
How are the points stored? If they are simply pairs of (X, Y), just sort using the Pythagorean theorem and take the one with the shortest distance. –  Adam Matan Aug 29 '10 at 10:02
add comment

3 Answers 3

up vote 1 down vote accepted

Id advise searching the archvied ESRI forums as this will have been asked before.

eg1 eg2 = You should be able to pinch some code from the snippets found there to at least get you started.

share|improve this answer
    
Tanks Simon.my problem is solved with using this sample code. –  Nima Aug 30 '10 at 7:13
    
Cool. Can you mark this as resolved please. You also failed to mark a previous Question I answered for you gis.stackexchange.com/questions/1340/… - Can you mark that one as resolved as well please. –  Simon Aug 30 '10 at 10:43
    
Sorry,But I click the green button next to your name.Should I do other work? –  Nima Aug 30 '10 at 12:53
    
this would be a better answer if it included one such example snippet or conversation. We can't rely on links to external sites to remain intact, and if/when it does change this answer will become wrong. –  matt wilkie Aug 30 '10 at 19:04
    
@Nima, click in the grey outline of a checkmark to mark an answer accepted: imgur.com/n48Bs.jpg –  matt wilkie Aug 30 '10 at 19:20
add comment

Take a look at the IProximityOperator or the IIndexQuery.

share|improve this answer
add comment

Assuming you have an ArcInfo license, have you tried calling the Near tool within your script? It sounds a lot like what you're after.

share|improve this answer
add comment

Your Answer

 
discard

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