<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Hi,<br><br>You need to have your points already in a table, then you can run a single query to identify the county each lies within. <br><br>SELECT p.point, c.county_nam <br>FROM county c, <br>             points p<br>WHERE  </span></font>ST_Within(p.the_geom, c.the_geom);<br><br>You can also wrap this in an update statement to have a column in the point table with the id of the county to implement a foreign key to join the two tables on.<br><br>HTH,<br><br>  Brent Wood<br><br>--- On <b>Wed, 12/29/10, Poynter, David <i><POYNTER@adeq.state.ar.us></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Poynter, David
 <POYNTER@adeq.state.ar.us><br>Subject: [postgis-users] Polygon from point query<br>To: "postgis-users" <postgis-users@postgis.refractions.net><br>Date: Wednesday, December 29, 2010, 8:49 AM<br><br><div id="yiv2032681492">


 


 

<style>
<!--
#yiv2032681492  
#yiv2032681492 p.yiv2032681492MsoNormal, #yiv2032681492 li.yiv2032681492MsoNormal, #yiv2032681492 div.yiv2032681492MsoNormal
        {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman";}
#yiv2032681492 a:link, #yiv2032681492 span.yiv2032681492MsoHyperlink
        {color:blue;text-decoration:underline;}
#yiv2032681492 a:visited, #yiv2032681492 span.yiv2032681492MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
#yiv2032681492 span.yiv2032681492EmailStyle17
        {font-family:Arial;color:windowtext;}
 _filtered #yiv2032681492 {margin:1.0in 1.25in 1.0in 1.25in;}
#yiv2032681492 div.yiv2032681492Section1
        {}
-->
</style>

<div class="yiv2032681492Section1">

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">This is probably an easy one, but being a PostGIS newb I've
been spinning my wheels and haven't the google fu to locate an answer, so here
goes...</span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I have a table of counties from the state (county) and I'm
creating a point to insert in another table and I would like to find the county
the point falls in.</span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I think I should be able to do it in one query rather than
looping thru county by county, but I can't seem to put it together.</span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">SELECT county_nam FROM county WHERE ?</span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p class="yiv2032681492MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I've been looking at ST_Within() and think the answer lies
with it somehow, thanks for any clues...</span></font></p>

</div>

 

</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>postgis-users mailing list<br><a ymailto="mailto:postgis-users@postgis.refractions.net" href="/mc/compose?to=postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></table>