Posts: 18
Registered: ‎07-17-2012
Message 1 of 2 (111 Views)

How to detect a nearest co-ordinate from an array of co-ordinates ?

111 Views, 1 Replies
07-18-2013 11:59 PM

Hi all,


I have an array of co-ordinates (List A) from a polyline. I have one of the co-ordinate (B) from a polyline which is located around the array of co-ordinates of the other polyline (List  A).


I want to detect the co-ordinate in List A which is closest to co-ordinate (B).


Known co-ordinates would be, 

1. Array of co-ordinates

2. the reference co-ordinate.

Can anyone help ?



Valued Contributor
Posts: 72
Registered: ‎12-03-2003
Message 2 of 2 (86 Views)

Re: How to detect a nearest co-ordinate from an array of co-ordinates ?

07-19-2013 05:25 AM in reply to: CodeBug

If what wou need is to get the nearest vertex, you could loop through all vertex and get the lowest value of:


        Math.Pow(vertex.X - coordinate.X, 2) + Math.Pow(vertex.Y - coordinate.Y, 2)


The lowest value indicates the nearest vertex.




But if you need the nearest point to the polyline, you could use the "GetClosestPointTo" method of the polyline.

Luis Alberto Manero, Geograma.com

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community