Finding distance between 2 lat longs

本文讨论了如何使用SharpMap库计算两点间的地理距离,并提供了将角度单位转换为线性距离(如米)的方法。同时提到了Haversine公式,这是一种常用的计算地球表面两点间大圆距离的数学方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Finding distance between 2 lat longs 
Tags: Geospatial Computation

May 15 2007 at 9:53 PM
Hi, I'd like to use the distance functions between two lat lon points but get distance in degrees rather than a more convenient distance such as metres. How do I use the SharpMap libraries to get the distance expressed as a linear unit between two points expressed as an angular unit? Thanks for any pointers.... Gavin

May 16 2007 at 4:39 PM
Hi,

if you have the distance in degrees you can convert those to metres by yourself using the following methods:

/// <summary>
/// Degrees to radians.
/// </summary>
/// <param name="degree">Value in degrees.</param>
/// <returns>Value in radians.</returns>
private static double DegreesToRadians(double degree)
{
return degree * Math.PI / 180.0;
}


/// <summary>
/// Converts radians to meters.
/// </summary>
/// <param name="radians">Value in radians.</param>
/// <returns>Value in meters.</returns>
private static double RadiansToMeters(double radians)
{
// there are 1852 meters in a nautical mile
// Radians to Nautical Miles: radians * 60 * 180 / Math.PI

return 1852 * (radians * 10800 / Math.PI);
}


Hope that helps.


Jo

May 16 2007 at 9:05 PM
Thanks! I've also just discovered this page
http://www.movable-type.co.uk/scripts/latlong.html
with the Haversine formula that seems to give results.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值