Excel 返回位置匹配/半径匹配

问题描述 投票:0回答:1

在过去的一天里,我一直在研究一种返回特定站点 1/4 英里和 1/2 英里半径范围内的位置的解决方案。有一个大约 3,000 个站点的列表,需要从投资组合(10,000 多个地点)中剔除,以查看它们是否落在投资组合中一个/多个地点的 1/4 英里和 1/2 英里半径范围内。所有位置数据均为十进制度格式。为了首先让事情正常工作,我制作了一个小的模拟数据集来使用。下面是用于下载该工作簿的 Google Drive 链接。到目前为止,我已经能够让网站返回投资组合中最接近的匹配以及该网站与投资组合匹配的距离。然而,在真实数据集中以及测试数据集中,投资组合中可能存在多个匹配项。为了让每个站点列出组合中 1/4 英里和 1/2 英里半径内的比赛,需要做什么?

Site List Screenshot

Portfolio Screenshot

距离公式

=INDEX(ACOS(COS(RADIANS(90-Portfolio!$C$2:$C$6)) *COS(RADIANS(90-C2)) +SIN(RADIANS(90-Portfolio!$C$2:$C$6)) *SIN(RADIANS(90-C2)) *COS(RADIANS(Portfolio!$D$2:$D$6-D2)))*3958.756,MATCH(SMALL((ABS(C2-Portfolio!$C$2:$C$6)^2+ABS(D2-Portfolio!$D$2:$D$6)^2)^(0.5),1),(ABS(C2-Portfolio!$C$2:$C$6)^2+ABS(D2-Portfolio!$D$2:$D$6)^2)^(0.5),0))

最近位置公式

=INDEX(Portfolio!$A$2:$A$6,MATCH(SMALL((ABS(C2-Portfolio!$C$2:$C$6)^2+ABS(D2-Portfolio!$D$2:$D$6)^2)^(0.5),1),(ABS(C2-Portfolio!$C$2:$C$6)^2+ABS(D2-Portfolio!$D$2:$D$6)^2)^(0.5),0))

谷歌云端硬盘链接

https://drive.google.com/uc?export=download&id=1eaDyUrjGjonV6iJkMa1Tac2v6NfquIsx
excel excel-formula powerquery latitude-longitude
1个回答
0
投票

如果您将数据导入 powerquery,这将生成从每个站点到每个投资组合的距离的完整列表,然后您可以根据需要进行过滤

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Site ID", type text}, {"Site Name", type text}, {"Latitude", type number}, {"Longitude", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Portfolio),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Site ID", "Site Name", "Latitude", "Longitude"}, {"Portfolio.Site ID", "Portfolio.Site Name", "Portfolio.Latitude", "Portfolio.Longitude"}),
#"Added Custom1" = Table.AddColumn(#"Expanded Custom", "DistanceMiles", each Number.Acos(Number.Sin(([Latitude] / 180) * Number.PI) * Number.Sin(([Portfolio.Latitude] / 180) * Number.PI) + Number.Cos(([Latitude] / 180) * Number.PI) * Number.Cos(([Portfolio.Latitude] / 180) * Number.PI) * Number.Cos( ([Portfolio.Longitude] / 180) * Number.PI-([Longitude] / 180) * Number.PI)) * 3959),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "DistanceKm", each Number.Acos(Number.Sin(([Latitude] / 180) * Number.PI) * Number.Sin(([Portfolio.Latitude] / 180) * Number.PI) + Number.Cos(([Latitude] / 180) * Number.PI) * Number.Cos(([Portfolio.Latitude] / 180) * Number.PI) * Number.Cos( ([Portfolio.Longitude] / 180) * Number.PI-([Longitude] / 180) * Number.PI)) * 6373)
in #"Added Custom2"

© www.soinside.com 2019 - 2024. All rights reserved.