2

I want to convert km to Latitude Longitude degrees in javascript.

I did not come across any thing as how to do that.

Any help will be much helpful.

Ofer Segev
  • 5,094
  • 2
  • 22
  • 22
user2882721
  • 221
  • 1
  • 3
  • 12
  • 3
    Unless I'm misunderstanding your question... Kilometres are a measure of distance, whereas degrees are a measure of temperature... they can't be converted... – Niet the Dark Absol Mar 25 '14 at 11:12
  • 2
    Degrees also measure lattitude and longitude, **but** it's not simple to convert, as it depends where you are – Chris Ballard Mar 25 '14 at 11:13
  • @NiettheDarkAbsol: degrees are also measure of angle. Maybe the OP means some geo-related transformations – Sergio Tulentsev Mar 25 '14 at 11:13
  • 4
    See http://www.movable-type.co.uk/scripts/latlong.html to understand how big a question this is ;) – Chris Ballard Mar 25 '14 at 11:15
  • @ChrisBallard I did consider that possibility, but as you say it's not easy! If you're 1/2πkm from the North Pole, then 1km East is a full 360 degrees! – Niet the Dark Absol Mar 25 '14 at 11:16
  • 1
    Exactly. Heading north/south you can make an assumption about the circumference of the earth and do the calc trivially, but east/west it depends how far above/below the equator you are – Chris Ballard Mar 25 '14 at 11:18
  • A minute (1/60th of a degree) equals 1.852 km – Tasos Mar 25 '14 at 11:20
  • 1
    @Tasos only on a line which is the full circumference of the earth - so the equator, or a line of longitude. Otherwise each degree represents less and less as you head away from the equator, converging on zero at the poles. – Chris Ballard Mar 25 '14 at 11:24
  • At the equator, the circumference of the earth is 24,902 miles, or 40,076 km. There are 360 degrees in a circle, and on the earth, so: 40076 / 360 = 111.32 km/degree (the accepted figure is 111.325 km). – Tasos Mar 25 '14 at 11:25
  • similar question here http://stackoverflow.com/questions/5217348/how-do-i-convert-kilometres-to-degrees-in-geodjango-geos – Tasos Mar 25 '14 at 11:28
  • beside the question has any sense to convert distance to coordinates, this is not a programming question, not suitable for SO. – serge Nov 03 '22 at 16:47

2 Answers2

0

If I get it correctly then you may use this formula:

1 minute of latitude North to south = 1 Nautical Mile 
1 Nautical Mile = 6075 feet 
1 degree = 60 Minutes
60 minutes = 60 * 6075 feet 
1 meter =3.28 Feet 
Hence 1 degree = 60 * 6075 / 3.28 Meters = 111,128 meters
And 1 kilometer = 1000 meters.

1 minute of Latitude = 1,852 Meters
1 degree = 60 * 1852 meters = 111.120 kilometers

So now you can do the conversions as you want.(Although degree in your question was confusing initially)

Also check Haversine formula - this states that for a great circle route the above applies. Beware that if not travelling a great circle route, degrees of latitude get closer together the further you are from the equator (the distance becomes zero at the poles).

Teemu
  • 22,918
  • 7
  • 53
  • 106
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

If you want to do conversions between geographical coordinate systems and (geodesic) distances, the best approach is probably to use a third-party library, as it is an involved subject once you progress beyond the spherical earth approximation. I have used the Javascript OpenLayers mapping library to make similar calculations in the oppopsite direction (lat/Lon pairs to distances). Take a look at the appropriate parts of the documentation for guidance

Max
  • 2,121
  • 3
  • 16
  • 20