我在GeoSeries中有Shapely点的列表。
coords.head():
0 POINT (-26.17690 80.81700)
1 POINT (-15.54390 80.61700)
2 POINT (-20.67690 80.36700)
3 POINT (6.10610 80.83300)
4 POINT (17.63910 79.88300)
Name: geometry, dtype: geometry
当我试图用命令获取压缩的坐标列表时,我发现了一个问题 pd.Series(zip(coords.geometry.x, coords.geometry.y)).head()
我得到下一个样本。
0 (-26.1769, 80.817)
1 (-15.5439, 80.617)
2 (-20.6769, 80.367)
3 (6.1061000000000005, 80.833)
4 (17.63909999999999, 79.883)
dtype: object
对了,举个例子 coords.geometry.x.head()
:
0 -26.1769
1 -15.5439
2 -20.6769
3 6.1061
4 17.6391
dtype: float64
同样奇怪的是,当我试图重现结果时。
new_coords = [(-26.17690, 80.81700),
(-15.54390, 80.61700),
(-20.67690, 80.36700),
(6.10610, 80.83300),
(17.63910, 79.88300)]
new_coords = gpd.GeoSeries([Point(p) for p in new_coords])
pd.Series(zip(new_coords.geometry.x, new_coords.geometry.y))
new_coords
Zip并没有表现得很奇怪。
0 POINT (-26.17690 80.81700)
1 POINT (-15.54390 80.61700)
2 POINT (-20.67690 80.36700)
3 POINT (6.10610 80.83300)
4 POINT (17.63910 79.88300)
dtype: geometry
主要目的是为了得到 准确 为了合并一帧数据,坐标的值,因此不能接受 zip 返回相似的值但不一样的情况。
看来@juanpa.arrivillaga 是正确的。在执行语句时 [float(p) for p in coords.geometry.x][:5]
我得到同样的数字。
[-26.1769, -15.5439, -20.6769, 6.1061000000000005, 17.63909999999999]
所以输入的数据并没有因为拉链而改变。