5

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.

  • 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
1

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.

  • 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
1

Take a look at the IProximityOperator or the IIndexQuery.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy