Extract latitude and longitude from coordinates

*爱你&永不变心* 提交于 2019-12-12 02:39:33

问题


I have this sort of data, and I want to extract the latitude and longitude in Python.

col[index]=
52.420223333,-1.904525
52.420221667,-1.904531667
52.420221667,-1.904536667
52.42022,-1.904545
52.420218333,-1.904553333
52.420216667,-1.904556667

I know how to do this in PHP, but wasn't sure how to implement it in Python:

sscanf($string, '"(%f, %f)"', $lat, $lng);

EDIT: This code runs and outputs the coordinates above

for index in range(len(col)):
    print col[index]

In the for loop, is it possible to get the lat and long data. e.g. for the first iteration, lat=52.420223333 and lon=-1.904525.


回答1:


for index in range(len(col)):
    lat, lon = col[index].split(",")
    print "lat=%s, lon=%s" % (lat, lon)


来源:https://stackoverflow.com/questions/20870765/extract-latitude-and-longitude-from-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!