简体   繁体   English

如何在 Python 中合并多个缓冲区对象?

[英]How to merge multiple buffer objects in Python?

Suppose I have several python.shapely.LineString objects.假设我有几个 python.shapely.LineString 对象。 I have built buffers around all of them, obtaining several buffered lines.我已经围绕所有这些构建了缓冲区,获得了几个缓冲行。 Now I would like to merge all these buffer shapes into one (a logical sum of all these shapes), but I can't treat them like Polygon objects, since they are just buffered lines.现在我想将所有这些缓冲区形状合并为一个(所有这些形状的逻辑总和),但我不能将它们视为 Polygon 对象,因为它们只是缓冲线。 Any advice how to do that?任何建议如何做到这一点?

unary_union can be used to "merge" a list of geometries. unary_union可用于“合并”几何列表。 Eg例如

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])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM