<html><head></head><body name="Mail Message Editor"><div><span class="Apple-style-span"><br></span></div><div id="replyPrefaceElement">On Mar 30, 2010, at 9:49:39 AM, "Karl Swartz" &lt;karl@kls2.com&gt; wrote:</div><br><blockquote style="padding-left: 5px; margin-left: 5px; border-left-width: 2px; border-left-style: solid; border-left-color: blue; color: blue; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="font-family: monospace; font-size: 11px; ">For the azimuth calculations, you can use Vincenty or similar if you<br>want high accuracy, or but you said small errors are acceptable so<br>basic spherical geometry may suffice.<br></span></span></blockquote><div><span class="Apple-style-span">The accuracy is not important, since the value of the azimuth does not matter; only its relative geometry does. The geometry is the same on the sphere and the ellipsoid except when the polygon include antipodes. If the polygon is that large then you need to consider more. You need to consider the very definition of "inside", since this is a closed surface we're talking about. None of the responses so far have addressed this problem.<br><div><span class="Apple-style-span" style=""><br></span></div><div><span class="Apple-style-span" style="">Regards,<div><span class="Apple-style-span" style="">— daan Strebe<div><span class="Apple-style-span" style=""><br></span></div></span></div></span></div><div><span class="Apple-style-span" style=""><br></span></div><div><div id="replyPrefaceElement">On Mar 30, 2010, at 9:49:39 AM, "Karl Swartz" &lt;karl@kls2.com&gt; wrote:</div><br><blockquote style="padding-left: 5px; margin-left: 5px; border-left-width: 2px; border-left-style: solid; border-left-color: blue; color: blue; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div id="felix-mail-header-block" style="color: black; background-color: white; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: silver; padding-bottom: 1em; margin-bottom: 1em; width: 749px; "><table border="0" cellpadding="1" cellspacing="1" width="100%"><tbody><tr><td width="70px" style="font-family: 'Lucida Grande'; font-size: 8pt; color: gray; text-align: right; vertical-align: top; font-weight: bold; "><span>From:</span></td><td style="font-family: 'Lucida Grande'; font-size: 8pt; color: black; text-align: left; vertical-align: top; padding-left: 5px; "><span title="&quot;Karl Swartz&quot; &lt;karl@kls2.com&gt;">"Karl Swartz" &lt;karl@kls2.com&gt;</span></td></tr><tr><td width="70px" style="font-family: 'Lucida Grande'; font-size: 8pt; color: gray; text-align: right; vertical-align: top; font-weight: bold; "><span>Subject:</span></td><td style="font-family: 'Lucida Grande'; font-size: 8pt; color: black; text-align: left; vertical-align: top; padding-left: 5px; "><span style="font-weight: bold; ">Re: [Proj] Coordinate within an area ?</span></td></tr><tr><td width="70px" style="font-family: 'Lucida Grande'; font-size: 8pt; color: gray; text-align: right; vertical-align: top; font-weight: bold; "><span>Date:</span></td><td style="font-family: 'Lucida Grande'; font-size: 8pt; color: black; text-align: left; vertical-align: top; padding-left: 5px; "><span>March 30, 2010 9:49:39 AM PDT</span></td></tr><tr><td width="70px" style="font-family: 'Lucida Grande'; font-size: 8pt; color: gray; text-align: right; vertical-align: top; font-weight: bold; "><span>To:</span></td><td style="font-family: 'Lucida Grande'; font-size: 8pt; color: black; text-align: left; vertical-align: top; padding-left: 5px; "><span title="&quot;PROJ.4 and general Projections Discussions&quot; &lt;proj@lists.maptools.org&gt;">"PROJ.4 and general Projections Discussions" &lt;proj@lists.maptools.org&gt;</span></td></tr></tbody></table></div><div id="felix-mail-content-block" style="color: black; background-color: white; width: 749px; "><div style="font-family: monospace; color: black; background-color: white; font-size: 8pt; ">&gt; &gt; My next questions would be: (1) how accurate does it need to be? and (2)<br>&gt; &gt; If it is done everywhere in the world, what projection to use to reduce<br>&gt; &gt; error?<br><br>&gt; 2/ We use global data, so it is everywhere in the world. I thought<br>&gt; about using Lambert azimuthal equal-area projection.<br><br>If you're working with lat/lon coordinates why would you be using a<br>projection at all?<br><br>For a point and a simple polygon that's not enormous, I'd calculate<br>paths and compare angles. Consider triangle ABC as the polygon and<br>you want to determine if point P is inside the triangle. Compute the<br>initial azimuth paths AB, AC, and AP. Then, determine if P lies within<br>angle A:<br><br>if azim(AB) &lt; azim(AC)<br>within(B) = azim(AP) &gt; azim(AB) &amp;&amp; azim(AP) &lt; azim(AC)<br>else<br>within(B) = azim(AP) &gt; azim(AC) &amp;&amp; azim(AP) &lt; azim(AB)<br><br>Repeat from angles B and C and if P is within all three angles then P<br>is within the triangle, otherwise it is not.<br><br>Note that the comparisons I used treat the boundaries of the triangle<br>as "not within" -- change the "within" comparisons to &gt;= and &lt;= to<br>include the boundaries of the polygon.<br><br>This algorithm can be trivially generalized to any convex n-sided<br>polygon.<br><br>For the azimuth calculations, you can use Vincenty or similar if you<br>want high accuracy, or but you said small errors are acceptable so<br>basic spherical geometry may suffice.<br><br>-- Karl</div><div><font class="Apple-style-span" face="monospace" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font></div></div></span></blockquote></div></span></div><div class="aol_ad_footer" id="u98F17E3903DF41488ECD6F483E70D74D"></div></body></html>