【问题标题】:Using foursquare API to get lat lon from addresses使用foursquare API从地址获取纬度
【发布时间】:2021-09-08 10:11:25
【问题描述】:

在最近的一个项目中,我使用foursquare 查找有关某个城市的场馆列表的信息,这让我开始思考。 Python 和foursquare(使用类别)确实可以帮助我完成另一个项目,但数据集完全是地址,没有纬度。

在我在网上看到的所有内容中,您都可以从场地名称中获取 lat lon,但不能从地址中获取。在我能够挖掘的代码块中,他们使用 nominatim 或 google 在进入 lat lon 进入foursquare之前进行地理定位,这看起来很愚蠢,但对于我的生活来说,我可以'找不到通过foursquare api从地址中获取lat lon的过程。 Foursquare 对调用的限制比 google 或特别是 nominatim 宽松得多。

谁能指出我正确的方向,或者有一个仅基于地址(街道地址、城市、邮编)从四方 api 获取 lat lon 的代码块?

【问题讨论】:

    标签: python api geolocation foursquare


    【解决方案1】:

    我不知道如何从foursquare API 获取纬度/经度,但有一种使用geopy 库的简单方法。

    将查询地理定位到地址和坐标:

    from geopy.geocoders import Nominatim
    geolocator = Nominatim(user_agent="specify_your_app_name_here")
    
    location = geolocator.geocode("175 5th Avenue NYC")
    
    print(location.address)
    Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ...
    
    print((location.latitude, location.longitude))
    (40.7410861, -73.9896297241625)
    

    【讨论】:

    • 谢谢,但我一直在寻找一种方法来获取 lot 位置的地理编码以及同时获取他们的业务类别,而 nominatim 没有。 :(
    • @J.Alexander 你可以在foursquare pypi 包之后使用此坐标获取任何foursquare 的信息:python client = foursquare.Foursquare(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET') client.venues.search(params={'query': 'coffee', 'll': '40.7233,-74.0030'}) github.com/mLewisLogic/foursquare
    猜你喜欢
    • 1970-01-01
    • 2012-02-22
    • 2010-12-02
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多