本文整理匯總了Python中Polygon.shift方法的典型用法代碼示例。如果您正苦於以下問題:Python Polygon.shift方法的具體用法?Python Polygon.shift怎麽用?Python Polygon.shift使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Polygon
的用法示例。
在下文中一共展示了Polygon.shift方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: reduceExample
# 需要導入模塊: import Polygon [as 別名]
# 或者: from Polygon import shift [as 別名]
def reduceExample():
# read Polygon from file
p = Polygon('testpoly.gpf')
# use ireland only, I know it's contour 0
pnew = Polygon(p[0])
# number of points
l = len(pnew[0])
# get shift value to show many polygons in drawing
bb = pnew.boundingBox()
xs = 1.1 * (bb[1]-bb[0])
# list with polygons to plot
plist = [pnew]
while l > 30:
# reduce points to the half
l /= 2
print "Reducing contour to %d points" % l
pnew = Polygon(reducePoints(pnew[0], l))
pnew.shift(xs, 0)
plist.append(pnew)
# draw the results
print "Plotting ReduceExample.svg"
drawSVG(plist, height=400, ofile="ReduceTest.svg")
示例2: reduceExample
# 需要導入模塊: import Polygon [as 別名]
# 或者: from Polygon import shift [as 別名]
def reduceExample():
# read Polygon from file
p = Polygon('testpoly.gpf')
# use ireland only, I know it's contour 0
pnew = Polygon(p[0])
# number of points
l = len(pnew[0])
# get shift value to show many polygons in drawing
bb = pnew.boundingBox()
xs = 1.1 * (bb[1]-bb[0])
# list with polygons to plot
plist = [pnew]
while l > 30:
# reduce points to the half
l /= 2
print 'Reducing contour to %d points' % l
pnew = Polygon(reducePoints(pnew[0], l))
pnew.shift(xs, 0)
plist.append(pnew)
# draw the results
writeSVG('ReducePoints.svg', plist, height=400)
if hasPDFExport:
writePDF('ReducePoints.pdf', plist)