0
단일 폴리곤을 만들기 위해 폴리곤 세트에 조인하려고합니다.오버레이없이 폴리곤 조인 (및 플롯)
poly1 = [(0,0), (1,0), (1,0.25), (1, 0.5), (1,0.75), (1,1), (0,1)]
poly2 = [(2,0), (2,0.25), (1,0.25), (1,0.5), (1,0.75), (2,1)]
다각형에서 "연결"것을 볼 수 있습니다 :이 다각형 (그들은 첫 번째와 동일하고 마지막 점에로 폐쇄되지 않음), 가장자리는 어떤 시점에서 정확히 동일한 (1,0.25), (1,0), (1,0.75)
어떻게이 폴리곤을 단일 폴리곤에 결합합니까?
내 현재 코드 : 나는 위의 코드를 실행하면
from __future__ import division
import pandas as pd
from shapely.geometry import Polygon,MultiPolygon
import os
import glob
from shapely.ops import cascaded_union
import matplotlib.pyplot as plt
from descartes import PolygonPatch
basePath = os.path.dirname(os.path.realpath(__file__)) # defines the directory where the current file resides
files = glob.glob(os.path.join(basePath, '*.txt'))
polygons = []
for f in files:
data = pd.read_csv(f, sep=';') # file containing a list of x and y points
points = []
for index, point in data.iterrows():
points.append((point['x'], point['y']))
polygons.append(Polygon(points))
u = cascaded_union(polygons)
fig2 = plt.figure(2, figsize=(10,10), dpi=90)
ax2 = fig2.add_subplot(111)
patch2b = PolygonPatch(u, fc=BLUE, ec=BLUE, alpha=1, zorder=2)
ax2.add_patch(patch2b)
가 작동하지 않습니다. x, y 좌표를 얻으려고하면 (다중 다각형입니다)