Ramiro,<div><br></div><div>The C API function OGR_R_IsValid( OGRGeometryH ) may help you.<br><br><div class="gmail_quote">On Fri, Mar 26, 2010 at 2:02 AM, Ramiro Gonzalez <span dir="ltr">&lt;<a href="mailto:ramirogonzalez@suremptec.com.ar">ramirogonzalez@suremptec.com.ar</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div>I won&#39;t calculate the area. I&#39;ll show an &#39;invalid area&#39; message to the user. </div>
<div><br>Thanks.<br><br></div>
<div class="gmail_quote">2010/3/19 Peter J Halls <span dir="ltr">&lt;<a href="mailto:P.Halls@york.ac.uk" target="_blank">P.Halls@york.ac.uk</a>&gt;</span><div><div></div><div class="h5"><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 &#39;winding&#39; method for calculating polygon areas would need tweaking to work with a shape like this, the &#39;complementary areas&#39; method or the triangulation method would.  See Stephen Wise, GIS Basics, London: Taylor &amp; Francis (2002) pp61-64 or Joseph O&#39;Rourke, Computational Geometry in C, Cambridge (2nd Edn): Cambridge University Press (1998) pp18-22.<br>

<br>Best wishes,<br><br>Peter 
<div><br><br>Chris &#39;Xenon&#39; 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 &#39;z&#39;.<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&#39;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&#39;d like to know<br>if there is a better way of knowing this.<br></blockquote><br> I&#39;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&#39;t do that. It&#39;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><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></div></div><br>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">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></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>
/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9848167848<br>17.2416N 80.1426E<br>
</div>