| From: Shi Mu | Is there any sample code to calculate the overlaid area between two | polygons? | Thanks! |
The polygon module at ( http://www.dezentral.de/warp.html?http://www.dezentral.de/soft/Polygon/ ) was found by googling for "polygon module python". If by "overlay" you mean the area in common between two polygons, it can handle this: ### >>> import Polygon >>> a=Polygon.Polygon(((0.,0.),(1.,0.),(0.,1.))) #it closes automatically back >>> to starting pt >>> b=Polygon.Polygon(((0.,0.),(1.,0.),(1.,1.))) >>> c = a & b >>> Polygon.pointList(c) [(1.0, 0.0), (0.0, 0.0), (0.5, 0.5)] >>> c.area() 0.25 >>> ### Note: the pdf docs did not appear to be included in the download from the page cited above; there is a link on the page cited above that downloads it for you. HTH, /c _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
