【问题标题】:Geocoding by Roadway Name Intersections按道路名称交叉口进行地理编码
【发布时间】:2019-06-13 13:12:52
【问题描述】:

我正在尝试获取道路交叉口的坐标,类似于您在 Google 地图中输入“1100 N 和 300 W”的方式,但给出了一个包含数万对的表格。有谁知道支持这种类型搜索的地理定位模块?

我正在测试 geopy,它可以轻松定位一条道路,甚至包括限制按区域(即城市或县)搜索的选项,但经过多次尝试更改我的测试交叉口措辞后仍然无法超越定位单一道路。

我尝试简单地将道路名称更改为更具描述性,即 CR 1100 N 和 CR 300 W...W CR 1100 N 和 N CR 300 W,但包含 CR 实际上会完全引发错误。

这是我目前所拥有的......

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="agent", format_string="%s, Madison County, IN")
location = geolocator.geocode("1100 N & 300 W")
print(location.address)
print(location.latitude)
print(location.longitude)

结果:

地址:North 300 West, Anderson, Madison County, Indiana, 46011, USA

纬度:40.142406 经度:-85.728747

预期纬度:40.262935 预期 Lon:-85.728308

【问题讨论】:

    标签: python geocoding geopy


    【解决方案1】:

    试试:https://geocoder.ca/1100%20N%20&%20300%20W%20ALEXANDRIA,%20IN

    这个十字街位置。 (1100 N & 300 W ALEXANDRIA IN) 40.262950, -85.72831

    也为 JSON:https://geocoder.ca/1100%20N%20&%20300%20W%20ALEXANDRIA,%20IN?json=1

    {“标准”:{“staddress”:“N&300”,“stnumber”:“1100”,“邮政”:“46063”,“street1”:“1100 N”,“city”:“亚历山大","prov":"IN","street2":"300 W","confidence":"0.8"},"longt":"-85.728310","TimeZone":"America/Indiana/Indianapolis","区号" : "765", "latt" : "40.262950"}

    【讨论】:

    • 这是我希望的输入/输出类型,但作为批处理代码。我希望能够为成千上万的街道对提供数据,并让它们产生纬度和经度。有没有办法通过 python 脚本向网站提供许多对,而无需打开网站?
    • 不,没有批处理模式。您需要遍历,一次发送一个请求。
    【解决方案2】:

    这是另一种批处理方法,我必须做类似的事情。请注意,您需要有效的互联网连接。

    # Python 3.6
    from geopy.geocoders import ArcGIS
    
    def my_LatLong(address):
        n = ArcGIS().geocode(address)
        # n is a list [0] = street names [1] = lat/long
        return n[1]
    
    with Open('file') as streets: 
    # do something
    # or you can us pandas.
    
        for i in streets:
            # i = line entry of street intersections
            print(my_LatLong(i))
            # write to file or do something
               
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 2020-02-14
      • 2017-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多