<?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: Create a polygon and test whether point(s) lie within? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745736#M21631</link>
    <description>&lt;P&gt;Proc Ginside requires x/y variables, but there's nothing saying they have to be anything 'special' (such as projected x/y values, etc). Therefore you could simply rename or duplicate your long/lat variables as x/y. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a simple example, where I just duplicate long/lat as x/y:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data my_coords;&lt;BR /&gt;input lat long;&lt;BR /&gt;&lt;STRONG&gt;x=long; y=lat;&lt;/STRONG&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;35.8252831 -78.7590949&lt;BR /&gt;38.8975995 -77.0366965&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data my_map; set mapsgfk.us_states (drop=x y);&lt;BR /&gt;&lt;STRONG&gt;x=long; y=lat;&lt;/STRONG&gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc ginside data=my_coords map=my_map out=my_coords;&lt;BR /&gt;id statecode;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=my_coords;&lt;BR /&gt;var lat long statecode;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ginside.png" style="width: 332px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60018i3DE4D0596C12B737/image-size/large?v=v2&amp;amp;px=999" role="button" title="ginside.png" alt="ginside.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jun 2021 11:44:31 GMT</pubDate>
    <dc:creator>GraphGuy</dc:creator>
    <dc:date>2021-06-04T11:44:31Z</dc:date>
    <item>
      <title>Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745309#M21618</link>
      <description>&lt;P&gt;I need to create a polygon and test whether a number of points lie within.&amp;nbsp; I've created the polygon&amp;nbsp; (from lat/long coordinates transformed to a Cartesian xy grid)&amp;nbsp; using the POLYGON function available in the&amp;nbsp; SG Annotation Function Dictionary.&amp;nbsp; But I don't know how to test whether a x,y point lies within or without.&amp;nbsp; Will PROC GINSIDE accept a polygon generated by the Polygon Function?&amp;nbsp; It seems dubious given that the annotation function is about drawing and not about "mapping" as seems to be a requirement for PROC GINSIDE.&amp;nbsp; Looking for some guidance on how best to proceed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745309#M21618</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-06-02T20:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745311#M21619</link>
      <description>So you're trying to now convert your polygon to a spatial file format that GINSIDE will be able to use with your point data? &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745311#M21619</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-02T20:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745315#M21620</link>
      <description>&lt;P&gt;I think that's what needs to happen but I don't know how to execute it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745315#M21620</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-06-02T20:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745331#M21621</link>
      <description>&lt;P&gt;GINSIDE wants a map data set.&lt;/P&gt;
&lt;P&gt;A map dataset comprises ordered pairs of coordinates with an identifier for the polygon. Best is to provide a closed polygon where the last pair of coordinates is the same as the beginning.&lt;/P&gt;
&lt;PRE&gt;data examplemap;
   input id x y;
datalines;
1   0 0
1   0 10
1   5 15
1   8 10
1   8 0
1   0 0
2   12  12
2   12  20
2   18  20
2   18  12
2   12  12
;


data exampledata;
   input otherid x y;
datalines;
1  0  .5
2  1  4
3  0  20
4  4  12
5  10 10
6  13 14
7  20 1
;

proc ginside map =examplemap
             data=exampledata
             out =result
             includeborder
;
   id id;
run;

      
&lt;/PRE&gt;
&lt;P&gt;The output data set has the coordinates of the Exampledata, and indicator 1/0 if the value is on the border, and the OTHERID of the data is matched with the ID from the Map data when the point is inside the area for the ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the Map data set doesn't have to be too complex as long as the Map and Data sets use the same coordinate systems.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 21:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745331#M21621</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-02T21:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745342#M21623</link>
      <description>&lt;P&gt;Thanks, ballardw, for your prompt reply.&amp;nbsp; I think I can make this solution work for my application and will mark it as accepted.&amp;nbsp; But if I run in to trouble, well, I'll be back...with more questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 21:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745342#M21623</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-06-02T21:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745344#M21624</link>
      <description>&lt;P&gt;Well, shoot!&amp;nbsp; I marked the wrong solution as "accepted".&amp;nbsp; How do I fix this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 21:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745344#M21624</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-06-02T21:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create a polygon and test whether point(s) lie within?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745736#M21631</link>
      <description>&lt;P&gt;Proc Ginside requires x/y variables, but there's nothing saying they have to be anything 'special' (such as projected x/y values, etc). Therefore you could simply rename or duplicate your long/lat variables as x/y. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a simple example, where I just duplicate long/lat as x/y:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data my_coords;&lt;BR /&gt;input lat long;&lt;BR /&gt;&lt;STRONG&gt;x=long; y=lat;&lt;/STRONG&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;35.8252831 -78.7590949&lt;BR /&gt;38.8975995 -77.0366965&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data my_map; set mapsgfk.us_states (drop=x y);&lt;BR /&gt;&lt;STRONG&gt;x=long; y=lat;&lt;/STRONG&gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc ginside data=my_coords map=my_map out=my_coords;&lt;BR /&gt;id statecode;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=my_coords;&lt;BR /&gt;var lat long statecode;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ginside.png" style="width: 332px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60018i3DE4D0596C12B737/image-size/large?v=v2&amp;amp;px=999" role="button" title="ginside.png" alt="ginside.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 11:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Create-a-polygon-and-test-whether-point-s-lie-within/m-p/745736#M21631</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2021-06-04T11:44:31Z</dc:date>
    </item>
  </channel>
</rss>

