<div>I won't calculate the area. I'll show an 'invalid area' message to the user. </div>
<div><br>Thanks.<br><br></div>
<div class="gmail_quote">2010/3/19 Peter J Halls <span dir="ltr"><<a href="mailto:P.Halls@york.ac.uk">P.Halls@york.ac.uk</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Whilst I agree with Chris that the 'winding' method for calculating polygon areas would need tweaking to work with a shape like this, the 'complementary areas' method or the triangulation method would. See Stephen Wise, GIS Basics, London: Taylor & Francis (2002) pp61-64 or Joseph O'Rourke, Computational Geometry in C, Cambridge (2nd Edn): Cambridge University Press (1998) pp18-22.<br>
<br>Best wishes,<br><br>Peter
<div class="im"><br><br>Chris 'Xenon' Hanson wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On 3/18/2010 10:20 AM, Ramiro Gonzalez wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I use gdal to calculate the area of polygons drawn by a user over a map.<br>The points are added to the polygon in same order the user selects them.<br>
An hourglass shaped polygon can be created adding 4 points like a 'z'.<br>When the polygon has the shape of an hourglass, the measure returned by<br>get_Area() is smaller than the sum of the areas of the two independent<br>
triangles.<br>I'd like to know if there is a way to calculate the area in this situation?<br>I tried to intersect the polygon with another that contains it but the<br>operation fails when the polygon cross itself(return NULL). I could use<br>
this to inform that the area calculated is invalid, but I'd like to know<br>if there is a better way of knowing this.<br></blockquote><br> I'm pretty sure this would be considered nonsensical topology. Area calculations usually<br>
rely on the points in a polygon winding either consistently clockwise or<br>counter-clockwise, but yours are mixed.<br><br> Don't do that. It's bad.<br><br> If you want to measure the area of a shape like that, create it out of two normal<br>
consistently-wound triangles stacked tip-to-tip.<br><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Thanks,<br>Ramiro<br></blockquote><br></blockquote><br>-- <br></div>--------------------------------------------------------------------------------<br>
<font color="#888888">Peter J Halls, GIS Advisor, University of York<br>Telephone: 01904 433806 Fax: 01904 433740<br>Snail mail: Computing Service, University of York, Heslington, York YO10 5DD<br>This message has the status of a private and personal communication<br>
--------------------------------------------------------------------------------</font>
<div>
<div></div>
<div class="h5"><br>_______________________________________________<br>gdal-dev mailing list<br><a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</div></div></blockquote></div><br>