geopandas에서 지오메트리는 매끈한 객체입니다. 당신이 geopandas의 GeoSeries이있는 경우
from shapely.geometry import Point, LineString
import geopandas
line1 = LineString([
Point(0, 0),
Point(0, 1),
Point(1, 1),
Point(1, 2),
Point(3, 3),
Point(5, 6),
])
line2 = LineString([
Point(5, 3),
Point(5, 5),
Point(9, 5),
Point(10, 7),
Point(11, 8),
Point(12, 12),
])
line3 = LineString([
Point(9, 10),
Point(10, 14),
Point(11, 12),
Point(12, 15),
])
print(line1.distance(line2))
> 0.5547001962252291
이/GeoDataFrame, 당신은 그것에 대해 좀 더 똑똑 할 필요가 : 두 매끈한 물체 사이의 거리를 얻으려면, 당신은 영리라는 이름의 distance
방법을 사용합니다.
gs = geopandas.GeoSeries([line1, line2, line3])
gs.distance(gs)
반환 모두 제로 때문에 모두 같은 형상 인 인덱스, 최대 gs
gs
에 일직선.
그러나 :
gs.distance(gs.shift())
당신에게 세 번째 줄에 2 호선을 1 호선에서 거리 및 2 호선을 제공합니다 :
0 NaN
1 0.554700
2 0.948683
dtype: float64
'line1.distance (2 호선)' –