从坐标中提取经度和纬度 [英] Extract latitude and longitude from coordinates

查看:159
本文介绍了从坐标中提取经度和纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  col [index]我有这种数据,我想用Python提取经度和纬度。 = 
52.420223333,-1.904525
52.420221667,-1.904531667
52.420221667,-1.904536667
52.42022,-1.904545
52.420218333,-1.904553333
52.420216667,-1.904556667

我知道如何在PHP中做到这一点,但不知道如何在Python中实现它:

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

编辑:
此代码运行并输出上面的坐标

 用于范围内的索引(len(col)):
print col [index]

在for循环中,是否可以获取纬度和长度数据。例如对于第一次迭代,lat = 52.420223333和lon = -1.904525。

解决方案

  (len(col)):
lat,lon = col [index] .split(,)
printlat =%s,lon =%s%(lat,lon)


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.

解决方案

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

这篇关于从坐标中提取经度和纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆