本文整理匯總了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