本文整理汇总了Python中Polygon.Polygon.simplify方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.simplify方法的具体用法?Python Polygon.simplify怎么用?Python Polygon.simplify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.simplify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_polygon
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import simplify [as 别名]
def generate_polygon(coords, scale):
"""
Generate a polygon that encompasses a set of grid coordinates.
:param coords: List of coordinates to draw polygon around
:param scale: Area around each grid square (1/scale in degrees is area of each point)
:return: Polygon of area representing the set of points
:return: Polygon of area representing the set of points
"""
out_poly = Polygon()
h_step = 0.51/scale
for pos in coords:
# sum up each polygon
out_poly.addContour([
(pos[0] - h_step, pos[1] - h_step),
(pos[0] + h_step, pos[1] - h_step),
(pos[0] + h_step, pos[1] + h_step),
(pos[0] - h_step, pos[1] + h_step)
])
out_poly.simplify()
return out_poly