【发布时间】: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