문제

Online 버퍼 (0)는 "수정"을 보았습니다.Shaply는 Bowtie의 교차점을 찾지만 오른쪽 상단 부분 만 유지합니다.해결 방법을 찾으려면 내 포인트의 순서를 반전 시도했습니다.놀랍게도 (나에게) Bowtie의 동일한 오른쪽상의 부분은 여전히 보관했습니다.나는 이해하지 못한다.어떤 도움이 감사드립니다.

전체 Bowtie를 두 개의 삼각형으로 유지하고 싶습니다 (Ore 1 6면 다각형 - 유용 할 수 있습니다).이 "문제"에 대한 해결 방법을 찾고 있습니다.

#!/usr/bin/env python3

from shapely.geometry.polygon import Polygon

bowtie_plot = [(1, 0), (0, 1), (0, -1), (-1, 0)]

bowties = [
        Polygon(bowtie_plot),
        Polygon(bowtie_plot[::-1])
        ]

cleaned = [
        bowties[0].buffer(0),
        bowties[1].buffer(0)
        ]

print('cleaned[0] exterior = {}'.format(list(cleaned[0].exterior.coords)))
# cleaned[0] exterior = [(0.0, 0.0), (-1.0, 1.0), (1.0, 1.0), (0.0, 0.0)]

print('cleaned[1] exterior = {}'.format(list(cleaned[1].exterior.coords)))
# cleaned[1] exterior = [(0.0, 0.0), (-1.0, 1.0), (1.0, 1.0), (0.0, 0.0)]

# ADDITIONAL INFORMATION BELOW
# here's what shapely *can* do with intersecting lines:
# a star shape made of five intersecting lines and five points

from math import sin, cos, pi

star = Polygon(
        [(cos(x*pi*4/5), sin(x*pi*4/5)) for x in range(5)]
        ).buffer(0)

# after buffering, becomes a star shape made out of ten lines and ten points
# shapely found all intersections and corrected the polygon.
print('list exterior = {}'.format(list(star.exterior.coords)))
.

그것에 대해 생각한 후에, 나는 이유를 이해할 수 있습니다 은 보우츠가 별과 다르게 대우받을 수 있지만 해결 방법을 찾는 데 관심이 있습니다.

다른 팁

buffer(0)가 항상 다중 폴리곤을 생성하는 것은 아닙니다 :

from shapely.wkt import loads

bt = loads('POLYGON ((0 0, 2 2, 2 0, 0 2, 0 0))')<br>
bt.buffer(0).wkt 

produces 'POLYGON ((1 1, 2 2, 2 0, 1 1))'
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top