![](/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.