# How to calculate distance from target coordinates to different coordinates

• ### Question

• Hello Everyone,
I started learning asp.net/c# recently. i need some help to achieve my assignment. I want to show distance of each coordinates from target location in a table like below.

Id            Target Coordinates(Lat & Long)                 Various Coordinates                Distance
1001                  43.662352, -79.382951                        43.666293, -79.387973
1002                  43.662352, -79.382951                        43.668271, -79.376153
1003                  43.662352, -79.382951                        43.669737, -79.394470

here how to calculate distance from Target coordinates to each coordinate by passing Id and showing in a table using asp.net web form(c#)

Learning Rocks

Friday, December 27, 2019 5:24 AM

• Do you want the global curved sphere distance or the straight line distance? How far apart are the points?

• Marked as answer by Sunday, December 29, 2019 2:33 PM
Friday, December 27, 2019 9:30 AM
• Questions related to ASP.NET need to be posted in the ASP.NET forums.

In answer to your distance between coordinates, as Tommy mentions, there are different algorithms available. Find the one you want to use and implement it. It is just a mathematical expression so it should be simple to do. Once you have your formula implemented then run it against each pair of coords. If you are having problems getting the correct value then post your formula code.

Michael Taylor http://www.michaeltaylorp3.net

• Marked as answer by Sunday, December 29, 2019 2:34 PM
Friday, December 27, 2019 3:09 PM
• In case you didn't appreciate Tommy's answer, here are more details.  Computing the distance between two points on an X,Y plane is easy.  It's the Pythagorean theorem you know from school: sqrt(x*x+y*y).  But the earth is not an X,Y plane.  The distance between two degrees of latitude is always the same (about 69 miles), but the distance between two degrees of longitude changes, from 69 miles at the equator down to 0 miles at the poles.  Thus, you have to use trigonometry.  It's not rocket science, but you'll need to look up a reference.

As a quick check, your first two points there (1001) are about 4900m apart.

Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

• Marked as answer by Sunday, December 29, 2019 2:34 PM
Friday, December 27, 2019 8:30 PM

### All replies

• Do you want the global curved sphere distance or the straight line distance? How far apart are the points?

• Marked as answer by Sunday, December 29, 2019 2:33 PM
Friday, December 27, 2019 9:30 AM
• Questions related to ASP.NET need to be posted in the ASP.NET forums.

In answer to your distance between coordinates, as Tommy mentions, there are different algorithms available. Find the one you want to use and implement it. It is just a mathematical expression so it should be simple to do. Once you have your formula implemented then run it against each pair of coords. If you are having problems getting the correct value then post your formula code.

Michael Taylor http://www.michaeltaylorp3.net

• Marked as answer by Sunday, December 29, 2019 2:34 PM
Friday, December 27, 2019 3:09 PM
• In case you didn't appreciate Tommy's answer, here are more details.  Computing the distance between two points on an X,Y plane is easy.  It's the Pythagorean theorem you know from school: sqrt(x*x+y*y).  But the earth is not an X,Y plane.  The distance between two degrees of latitude is always the same (about 69 miles), but the distance between two degrees of longitude changes, from 69 miles at the equator down to 0 miles at the poles.  Thus, you have to use trigonometry.  It's not rocket science, but you'll need to look up a reference.

As a quick check, your first two points there (1001) are about 4900m apart.

Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

• Marked as answer by Sunday, December 29, 2019 2:34 PM
Friday, December 27, 2019 8:30 PM