gpt4 book ai didi

python - 从 Shapely 中的多边形中提取点/坐标

转载 作者:IT老高 更新时间:2023-10-28 20:34:02 26 4
gpt4 key购买 nike

如何获取/提取定义 shapely 多边形的点?谢谢!

形状多边形示例

from shapely.geometry import Polygon

# Create polygon from lists of points
x = [list of x vals]
y = [list of y vals]

polygon = Polygon(x,y)

最佳答案

诀窍是使用 Polygon 类方法的组合:

from shapely.geometry import Polygon

# Create polygon from lists of points
x = [0.0, 0.0, 1.0, 1.0, 0.0]
y = [0.0, 1.0, 1.0, 0.0, 0.0]

poly = Polygon(zip(x,y))

# Extract the point values that define the perimeter of the polygon
xx, yy = poly.exterior.coords.xy

# Note above return values are of type `array.array`
assert x == xx.tolist()
assert y == yy.tolist()

关于python - 从 Shapely 中的多边形中提取点/坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20474549/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com