Hi all,
I'm not able to compute the area of a polygon using G_area_of_polygon,
I define a square with coords: [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]) with:
from pygrass.vector.geometry import Boundary
bound = Boundary(points=[(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)])
Check the content of the C structure, with:
for i in xrange(bound.c_points.contents.n_points):
... print i, " (%.1f, %.1f)" % (bound.c_points.contents.x[i],
bound.c_points.contents.y[i])
...
0 (0.0, 0.0)
1 (0.0, 2.0)
2 (2.0, 2.0)
3 (2.0, 0.0)
4 (0.0, 0.0)
It seems ok to me, now use the G_area_polygon function...
import grass.lib.gis as libgis
libgis.G_area_of_polygon(bound.c_points.contents.x,
... bound.c_points.contents.y,
... bound.c_points.contents.n_points)
0.0
Why G_area_of_polygon doesn't return 4.0? What is it wrong?
Best regards
Pietro
Hi,
2013/1/20 Pietro <peter.zamb@gmail.com>:
I'm not able to compute the area of a polygon using G_area_of_polygon,
try to call before G_area_of_polygon() fn
G_begin_polygon_area_calculations(). It should help.
Martin
--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
On Sun, Jan 20, 2013 at 5:33 PM, Martin Landa <landa.martin@gmail.com> wrote:
Hi,
2013/1/20 Pietro <peter.zamb@gmail.com>:
I'm not able to compute the area of a polygon using G_area_of_polygon,
try to call before G_area_of_polygon() fn
G_begin_polygon_area_calculations(). It should help.
Thank you Martin!
it's working
libgis.G_begin_polygon_area_calculations()
1
libgis.G_area_of_polygon(bound.c_points.contents.x,
... bound.c_points.contents.y,
... bound.c_points.contents.n_points)
4.0
Hi,
good to know. I noted this in documentation (r54720) supposing that
this is always true.
Please, try things like these note in documentation.
Vaclav
On 20 January 2013 17:42, Pietro <peter.zamb@gmail.com> wrote:
On Sun, Jan 20, 2013 at 5:33 PM, Martin Landa <landa.martin@gmail.com> wrote:
Hi,
2013/1/20 Pietro <peter.zamb@gmail.com>:
I'm not able to compute the area of a polygon using G_area_of_polygon,
try to call before G_area_of_polygon() fn
G_begin_polygon_area_calculations(). It should help.
Thank you Martin!
it's working
libgis.G_begin_polygon_area_calculations()
1
libgis.G_area_of_polygon(bound.c_points.contents.x,
... bound.c_points.contents.y,
... bound.c_points.contents.n_points)
4.0
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev