【问题标题】:Inaccurate resulte from Bing Maps Geocode DataflowBing 地图地理编码数据流的结果不准确
【发布时间】:2021-06-02 00:38:54
【问题描述】:

我正在使用 Python POST 请求对我公司分支机构的地址进行地理编码,但得到的结果非常不准确。

我查看了this 的答案,但问题是某些结果没有得到处理。我的问题不同,我的结果所有都不准确,即使是Confidence="High" 的结果也不准确。而且我确实有一个企业帐户。

以下是说明如何创建地理编码作业和上传数据的文档:
https://docs.microsoft.com/en-us/bingmaps/spatial-data-services/geocode-dataflow-api/create-a-geocode-job-and-upload-data

这是我要上传的代码的基本版本:

import requests    

SDS_Geocode_URL = "https://spatial.virtualearth.net/REST/v1/dataflows/geocode?"

geocode_post_vars = {
    "input": "xml",
    "output": "json",
    "content-type": "application/xml",
    "key": Bing_key,
}

geocode_Post_URL = (
    SDS_Geocode_URL
    + urllib.parse.urlencode(geocode_post_vars)
    + "&dataLocation="
    + "https://account-name.blob.core.windows.net/myDataFile.xml"
)

r = requests.post(geocode_Post_URL)

一旦数据被地理编码,我使用 GET 请求来获取地理编码的 XML

geocode_Results = requests.get(
    "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/"
    + jobID
    + "/output/succeeded?key=" + Bing_key
)

print(geocode_Results.text)

我得到这样的结果:

<GeocodeEntity Id="12040000">
    <GeocodeRequest Culture="en-US" IncludeNeighborhood="true" Query="Rush Truck Center - Los Angeles" IncludeQueryParse="true">
        <Address AddressLine="8830 Slauson Ave, Pico Rivera, CA 90660" AdminDistrict="California" CountryRegion="US" Locality="Pico Rivera" PostalCode="90660" />
    </GeocodeRequest>
    <GeocodeResponse Name="Los Angeles, CA" EntityType="PopulatedPlace" Confidence="High" MatchCodes="UpHierarchy">
        <Address AdminDistrict="CA" CountryRegion="United States" AdminDistrict2="Los Angeles County" FormattedAddress="Los Angeles, CA" Locality="Los Angeles" />
        <GeocodePoint CalculationMethod="Rooftop" Latitude="34.0522384643555" Longitude="-118.243347167969" Type="Point" UsageTypes="Display" />
        <QueryParseValue Property="Locality" Value="Los Angeles" />
        <BoundingBox SouthLatitude="33.6968193054199" WestLongitude="-118.683807373047" NorthLatitude="34.3506469726563" EastLongitude="-118.138854980469" />
        <Point Latitude="34.0522384643555" Longitude="-118.243347167969" />
    </GeocodeResponse>
    <StatusCode>Success</StatusCode>
    <TraceId>#######</TraceId>
</GeocodeEntity>

在我的地理编码请求中,我有一个特定的地址和公司分支机构名称(已针对此问题进行了编辑)。此外,我添加了与文档中所述完全相同的城市、州、国家和邮政编码属性。

即使有了所有这些信息,地理编码的响应数据返回的粒度也不比一般的洛杉矶市更精细,城市的纬度/经度坐标,而不是我提供的地址(为了记录,它距离它应该的位置有 10 英里远)是)。

此外,当我通过 Bing 地图门户手动上传 XML 文件时,它非常准确。我的请求格式是否错误,或者这是 Bing 问题?

【问题讨论】:

    标签: python xml post geocoding bing-maps


    【解决方案1】:

    我在您的请求数据中发现了几个问题:

    • 您传入的“查询”值是兴趣点名称和位置的组合。地理编码器仅适用于地址。因此,在这种情况下,兴趣点名称被删除,地理编码器仅使用“洛杉矶”,因此结果。
    • 您将两种不同的地理编码查询类型混合到一个查询中。要么只使用“查询”,要么只使用单个地址部分(AddressLine、Locality、AdminDistrict、CountryRegion、PostalCode)。在这种情况下,“查询”值被使用而其他所有内容都被忽略,使用单个地址部分将比您的查询准确得多。
    • 您将完整地址传递到 AddressLine 字段。那应该只是街道地址(即“8830 Slauson Ave”)。

    这是请求的修改版本,可能会返回您期望的信息:

    <GeocodeRequest Culture="en-US" IncludeNeighborhood="true" IncludeQueryParse="true">
            <Address AddressLine="8830 Slauson Ave" AdminDistrict="California" CountryRegion="US" Locality="Pico Rivera" PostalCode="90660" />
        </GeocodeRequest>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      相关资源
      最近更新 更多