This content has been marked as final. Show 6 replies
please post code that doesn't work.
I found example of BufferSnap in help
IProximityOperator proximityOp = point as IProximityOperator;
double Dist = proximityOp.ReturnDistance(outPoly);
I've build myself a code to find the nearest street of a point, and it is quite simple. I did not use any namespace, only math functions. So, if you want to give it a try, look for Heron's formula, which I think is the cheapest for computing. The formula gives you a height of a triangule using the sides. Maybe IProximityOperator give you best results, but I've never worked with it.
Thanks for the speedy responses Dubravko & Rodrigo.
I�??ve attached the code I am trying to get to work to this reply (I hope!).
It was taken off one of the old forum subjects from 2002, so maybe the problem is that I�??m using a newer version of ArcGIS? This code has the proximity operator function in it. I just don�??t know if it won�??t run because of an issue with the code, or the way I�??m trying to run it. It does seem that the Macro function doesn�??t register any more than the first Sub. Could this be the issue? If so, how do I fix it?
Rodrigo �?? thanks for your advice. I�??m not sure how Heron�??s formula works though. If it needs a triangle, where does it get the three points from? I�??m afraid my maths skills are almost as bad as my computer skills! :o
I can't run your code right now, I'll do it since I can. About the points, one may be the point you are interested, and the other two may be the edges of your line. You must calculate de distance from one tho another (you have one, the length of the segment, so it's just two calculations). After that, you use the 3 sides in Heron's formula, to get the distance of each point to the line.
I assure you, it's not difficult to do.
Jo this is simple task to do. If you would like to dive into ArcObjects you should get a lot of patience and reading SDK.
This is simple code that you can adopt to your needs.
IFeature pLine = Temp_Line.GetLayer().FeatureClass.GetFeature(6); IFeature pPoint = Temp_Point.GetLayer().FeatureClass.GetFeature(1); IProximityOperator pProximity = pPoint.Shape as IProximityOperator; double distance = pProximity.ReturnDistance(pLine.Shape);This is all you should do to calculate distance.
Run the geoprocessing tool called Near with points as input and lines as near features. Or run Generate Near Table if you want more than one closest lines.
Follow examples in this topic (valid for 9.2 onward):
Take the avtange of built-in ArcGIS validation.