在Python3中将str(location)转换为tuple of(Longitude,Latitude)吗?

2024-09-29 22:22:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我在网上搜资料,从中我得到了一个地点的清单。我要把经度和经度分别转换。我找到了geopy它看起来做得很好。在

无论是否有geopy,如何从Python 3.5内将该列表转换为它们各自的坐标(lon: (from -180,180) and lat: (from -90,90))

最好是精确的坐标,但如果不可能,一般的区域坐标也可以。在

我找到了我试图模仿的资源https://pypi.python.org/pypi/geopy

#Convert to Longitude/Latitude
from geopy.geocoders import Nominatim

geolocator = Nominatim()

locations = ['Kahekili Beach/Old Airport Beach, Leeward Shore Maui', 'Outside Honokohau Harbor South / Naia / Ripoff Reef, North Kona Coast', 'Ulua Beach, Leeward Shore Maui', 'Kaiwi Pt./Arch Cave/Wash Rock/Sand Channel/Kamanu/Devils Doorway, North Kona Coast', 'Honolua Bay MLCD, Leeward Shore Maui', 'Golden Arches', 'Lone Tree Arch / Freeze Face Cave, North Kona Coast', 'Old Airport', 'Turtle Heaven, North Kona Coast', 'Turtle Pinnacle/Turtle Towers/North of Honokohau Harbor Entrance/Terrapin Station/Turtle Pai, North Kona Coast']    
for location in locations:
    location = geolocator.geocode(location)


Error
 +Service timed out

Tags: frompypilocationturtlegeopynorthgeolocatornominatim

热门问题