[GRASS-SVN] r54719 - grass/trunk/lib/python/pygrass/vector
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jan 20 09:19:29 PST 2013
Author: zarch
Date: 2013-01-20 09:19:29 -0800 (Sun, 20 Jan 2013)
New Revision: 54719
Modified:
grass/trunk/lib/python/pygrass/vector/geometry.py
Log:
Add area method to Boundary class
Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py 2013-01-20 17:19:20 UTC (rev 54718)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py 2013-01-20 17:19:29 UTC (rev 54719)
@@ -1004,7 +1004,20 @@
left, right)
return left.contents.value, right.contents.value
+ def area(self):
+ """Return the area of the polygon.
+ ::
+ >>> bound = Boundary([(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)])
+ >>> bound.area()
+ 4
+ .."""
+ libgis.G_begin_polygon_area_calculations()
+ return libgis.G_area_of_polygon(self.c_points.contents.x,
+ self.c_points.contents.y,
+ self.c_points.contents.n_points)
+
+
class Centroid(Point):
"""The Centroid class inherit from the Point class.
Centroid contains an attribute with the C Map_info struct, and attributes
More information about the grass-commit
mailing list