1

假设我有几个 python.shapely.LineString 对象。我已经围绕它们建立了缓冲区,获得了几条缓冲线。现在我想将所有这些缓冲区形状合并为一个(所有这些形状的逻辑总和),但我不能将它们视为 Polygon 对象,因为它们只是缓冲线。任何建议如何做到这一点?

4

1 回答 1

4

unary_union可用于“合并”几何列表。例如

from shapely.geometry import LineString
from shapely.ops import unary_union

lines = [
    LineString([(845, 555), (365, -5), (130, -650)]),
    LineString([(740, 605), (640, 60), (315, -375)]),
    LineString([(0, -500), (655, -150), (900, 300)]),
]

# Two example unions
unioned_lines = unary_union(lines)
unioned_buffered_poly = unary_union([l.buffer(50) for l in lines])
于 2014-07-14T20:58:28.957 回答