<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding the area of an irregular polygon in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203500#M10912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data elipse;&lt;/P&gt;&lt;P&gt;&amp;nbsp; pi=4*atan(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=0 to 256 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=cos(i*2*pi/256);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y=2*sin(i*2*pi/256);&lt;/P&gt;&lt;P&gt; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set elipse end=eof;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain area lastx lasty;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _N_=1 then area=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; area+((lastx-x)*(y+lasty)/2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lastx=x;lasty=y;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if eof then put area=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Aug 2015 14:34:44 GMT</pubDate>
    <dc:creator>JacobSimonsen</dc:creator>
    <dc:date>2015-08-20T14:34:44Z</dc:date>
    <item>
      <title>Finding the area of an irregular polygon</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203498#M10910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to find the area for an irregular polygon. My dataset consists of many points but the example below contains just 8 coordinates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a good algorithm available for doing this? Ideally generalizing it so that it can apply to potentially 100s of points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data coord;&lt;/P&gt;&lt;P&gt;input x 1. y 1.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;31&lt;/P&gt;&lt;P&gt;53&lt;/P&gt;&lt;P&gt;87&lt;/P&gt;&lt;P&gt;79&lt;/P&gt;&lt;P&gt;58&lt;/P&gt;&lt;P&gt;47&lt;/P&gt;&lt;P&gt;25&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 11:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203498#M10910</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2015-08-20T11:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the area of an irregular polygon</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203499#M10911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These computational geometry questions might be better to ask in the SAS Support Community for Graphics, which includes experts in mapping and GIS. Goto &lt;A _jive_internal="true" href="https://communities.sas.com/community/support-communities/sas_graph_and_ods_graphics"&gt;https://communities.sas.com/community/support-communities/sas_graph_and_ods_graphics&lt;/A&gt; They might know of a built-in function or macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These computations are possible to do in the DATA step, but they are much easier in a vector language like SAS/IML.&lt;/P&gt;&lt;P&gt;A simple internet search will reveal many web pages that discuss formulas for the area of a general polygon. For example, see &lt;A href="http://geomalgorithms.com/a01-_area.html" title="http://geomalgorithms.com/a01-_area.html"&gt;Area of Triangles and Polygons&lt;/A&gt;. The following SAS/IML function implements the second summation formula after the paragraph that begins "One can make the formula more explicit by..."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;start AreaPolygon(_x, _y);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; /* close polygon by appending first point to end */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; y = _y // _y[1]; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; x = _x // _x[1]; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; n = nrow(x);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; xx = x[ 1:(n-1) ] + x[ 2:n ];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; yy = y[ 2:n ] - y[ 1:(n-1) ];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; A = 0.5 * sum(xx # yy); /* is negative for clockwise polys */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return( abs(A) );&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use coord; read all var {x y}; close;&lt;BR /&gt;A = AreaPolygon(x,y);&lt;BR /&gt;print A;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 12:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203499#M10911</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-08-20T12:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the area of an irregular polygon</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203500#M10912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data elipse;&lt;/P&gt;&lt;P&gt;&amp;nbsp; pi=4*atan(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=0 to 256 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=cos(i*2*pi/256);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y=2*sin(i*2*pi/256);&lt;/P&gt;&lt;P&gt; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set elipse end=eof;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain area lastx lasty;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _N_=1 then area=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; area+((lastx-x)*(y+lasty)/2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lastx=x;lasty=y;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if eof then put area=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 14:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Finding-the-area-of-an-irregular-polygon/m-p/203500#M10912</guid>
      <dc:creator>JacobSimonsen</dc:creator>
      <dc:date>2015-08-20T14:34:44Z</dc:date>
    </item>
  </channel>
</rss>

