如何获取/提取定义 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 类方法的组合来实现这一点。

如果您想要测地坐标,则需要将它们转换回 WGS84(通过 pyprojmatplotlibbasemap 或其他方式)。

from shapely.geometry import Polygon

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

some_poly = Polygon(x,y)

# Extract the point values that define the perimeter of the polygon
x, y = some_poly.exterior.coords.xy

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

10-12 23:23