2014-12-31 12 views
0

저는 Python, Shapely 및 Fiona로 작업하고 있습니다. 사용할 수있는 두 개의 shapefile이 있음을 고려하면, 선 shapefile과 다각형 shapefile.선 대 다각형 교차 좌표

교차점 (Q 표시로 표시)과 해당 좌표로 구성된 최종 결과 모양 파일을 얻는 방법 ??

enter image description here

+0

[질문에 대한 추가 그림] (HTTP : // gis.stackexchange.com/questions/127878/line-vs-polygon-intersection-coordinates) – Akhil

+0

질문을 편집했습니다. 지금 더 명확 해? – Akhil

+0

나는 매끄러운 (기하학 교차점)의 '교차점'기능을 사용하고 출력을 작성하기 위해 피오나 (Fiona)를 사용하여 간단한 교차점을 사용해 보았습니다. – Akhil

답변

1

당신은 다각형과 라인의 외부에서 교차로를 얻을 필요가있다. 대신 다각형과 교집합을 사용하면 다각형에 면적이 있으므로 결과는 선입니다. 그들이 평행 경우에도, 교회법, 선을 할 수있다, 그래서 당신은 또한 GeometryCollection 여기

을 시작으로 뭔가 기대할 수 :

from shapely.wkt import loads 

poly = loads('POLYGON ((140 270, 300 270, 350 200, 300 150, 140 150, 100 200, 140 270))') 
line = loads('LINESTRING (370 290, 270 120)') 

intersection = poly.exterior.intersection(line) 

if intersection.is_empty: 
    print("shapes don't intersect") 
elif intersection.geom_type.startswith('Multi') or intersection.geom_type == 'GeometryCollection': 
    for shp in intersection: 
     print(shp) 
else: 
    print(intersection)