使用加权多点定位法找到未知点

4

我在地球上有一系列点(纬度/经度坐标),以及从每个点到一个未知位置的一系列距离估计值。我想使用多基地定位来估算这个未知位置的位置。从简单的例子开始,假设有4个点和与未知点的关联距离估计:

下面是纬度、经度、距离估计3元组:

p1 = (31.2297, 121.4734, 3335.65)                           
p2 = (34.539, 69.171, 2477.17)                          
p3 = (47.907, 106.91, 1719.65)                      
p4 = (50.43, 80.25, 1242.27) 

已经在这里这里解释了如何找到未知点。使用上面的例子,未知点位于纬度/经度坐标:36.989, 91.464。
我的问题很独特,因为我正在寻找一种带权多边定位的方法。每个距离估计只是一个估计值;测量不精确,但距离越小,测量越准确。我想使用多边定位,但我希望在确定最终答案时给与与更小距离估计相关联的点更多“权重”,因为这些更短的估计更准确。我该怎么做?我正在寻找Python的解决方案。
回到之前的例子,但引入误差,我想再次找到点的未知位置:
p1 = (31.2297, 121.4734, 4699.15)           
p2 = (34.539, 69.171, 2211.97)        
p3 = (47.907, 106.91, 1439.75)                              
p4 = (50.43, 80.25, 1222.07)    

你能描述一下每个测量所关联的误差估计如何随距离变化而变化吗?它是线性增加还是二次增加? - ali_m
这是一个很好的问题。为了简单起见,让我们假设它是线性的。 - turtle
1个回答

3

虽然这可能不是您要寻找的确切内容,但您可以将其用作起点:

import numpy as np
import scipy.optimize as opt

#Returns the distance from a point to the list of spheres
def calc_distance(point):
    return np.power(np.sum(np.power(centers-point,2),axis=1),.5)-rad

#Latitude/longitude to carteisan
def geo2cart(lat,lon):
    lat=np.deg2rad(lat)
    lon=np.deg2rad(lon)
    points=np.vstack((earth_radius*np.cos(lat)*np.cos(lon),
           earth_radius*np.cos(lat)*np.sin(lon),
           earth_radius*np.sin(lat))).T
    return points

#Cartesian to lat/lon
def cart2geo(xyz):
    if xyz.ndim==1: xyz=xyz[None,:]
    lat=np.arcsin(xyz[:,2]/earth_radius)
    lon=np.arctan2(xyz[:,1],xyz[:,0])
    return np.rad2deg(lat),np.rad2deg(lon)

#Minimization function. 
def minimize(point):
    dist= calc_distance(point)
    #Here you can change the minimization parameter, here the distances
    #from a sphere to a point is divided by its radius for linear weighting.
    err=np.linalg.norm(dist/rad)
    return err

earth_radius = 6378
p1 = (31.2297, 121.4734, 3335.65)
p2 = (34.539, 69.171, 2477.17)
p3 = (47.907, 106.91, 1719.65)
p4 = (50.43, 80.25, 1242.27)

points = np.vstack((p1,p2,p3,p4))
lat    = points[:,0]
lon    = points[:,1]
rad    = points[:,2]

centers = geo2cart(lat,lon)

out=[]
for x in range(30):
    latrand=np.average(lat/rad)*np.random.rand(1)*np.sum(rad)
    lonrand=np.average(lon/rad)*np.random.rand(1)*np.sum(rad)
    start=geo2cart(latrand,lonrand)
    end_pos=opt.fmin_powell(minimize,start)
    out.append([cart2geo(end_pos),np.linalg.norm(end_pos-geo2cart(36.989,91464))])


out = sorted(out, key=lambda x: x[1])
print 'Latitude:',out[0][0][0],'Longitude:',out[0][0][1],'Distance:',out[0][1]

我们得到:
First set of points:  lat 40.1105092 lon 88.07068701
Second set of points: lat 40.36636421 lon 88.84527729

我相信有更好的方式,但至少你可以通过调整权重和误差函数来看看会发生什么。当然存在几个严重问题之一是可能会陷入局部最优。可能有一种最小二乘方法来解决这个问题-只是我目前没有看到。

为了双重检查,这是否可行:

p0=np.random.rand(2)*90+20
p1=np.random.rand(2)*-10+20+p0
p2=np.random.rand(2)*-10+20+p0
p3=np.random.rand(2)*-10+20+p0
p4=np.random.rand(2)*-10+20+p0

target=geo2cart(p0[0],p0[1])
points=np.vstack((p1,p2,p3,p4))
lat    = points[:,0]
lon    = points[:,1]

centers=geo2cart(lat,lon)
#You can change the random at the end to tune the amount of noise
rad =  np.power(np.sum(np.power(centers-target,2),axis=1),.5)#+np.random.rand(4)*10    

print '------------'
start=geo2cart(np.average(lat),np.average(lon))
end_pos=opt.fmin_powell(minimize,start)
print 'Exact',p0
print 'Start guess',cart2geo(start)
print 'Found',cart2geo(end_pos)
print 'Distance',np.linalg.norm(end_pos-target)

Exact [  45.21292244  101.85151772]
Start guess (array([ 60.63554123]), array([ 115.08426225]))
Found (array([ 45.21292244]), array([ 101.85151772]))
Distance 5.30420680512e-11

感谢您的出色工作。有一件事我不明白,就是您是从哪里获取第一组和第二组点的答案的。例如,对于第一组点,您得到了一个解决方案为40.1105092, 88.07068701,这与实际位置相差很远(约500公里)。此外,当我运行您的脚本时,cart2geo()给出的预测经纬度为54.85960821, 89.49203514,而不是40.1105092, 88.07068701。我的理解正确吗?您能详细解释一下吗? - turtle
我在尝试不同的起始点 - 正如先前提到的,你可能会陷入局部最小值的困境。原始数据中有什么样的噪音?对噪声进行微小的更改可能会大大影响结果。此外,在SVD下的第二组点给出了截然不同的结果。 - Daniel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接