![](/img/trans.png)
[英]How to extract latitude and longitude pairs as a list from a LineString geopandas dataframe
[英]How to reverse a list of latitude and longitude coordinate pairs?
我有一个元组列表,其中每个元组包含一对坐标。 我想反转每个点的坐标。
我有一个 dataframe,一个名为“coord”的特定列包含每行的纬度和经度坐标对列表,我想反转每行的坐标对。
例如,第一行看起来像这样
[(52.34725, 4.91790),
(52.34715, 4.91797),
(52.34742, 4.91723),
(52.34752, 4.91713)]
我试过这个 function,但它不起作用。
result = [[p[1], p[0]] for p in x]
预期的 output 为:
[(4.91790, 52.34725),
(4.91797, 52.34715),
(4.91723, 52.34742),
(4.91713, 52.34752)]
尝试:
reversed = [item[::-1] for item in x]
y = [(xx[1],xx[0]) for xx in x] y # [(4.9179, 52.34725), (4.91797, 52.34715), (4.91723, 52.34742), (4.91713, 52.34752)]
另一种可能的解决方案:
y = []
for i, j in x:
y.append((j, i))
Output:
[(4.9179, 52.34725), (4.91797, 52.34715), (4.91723, 52.34742), (4.91713, 52.34752)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.