Hi,

You need to have your points already in a table, then you can run a single 
query to identify the county each lies within. 

SELECT p.point, c.county_nam 
FROM county c, 
             points p
WHERE  ST_Within(p.the_geom, c.the_geom);

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.

HTH,

  Brent Wood

--- On Wed, 12/29/10, Poynter, David <[email protected]> wrote:

From: Poynter, David <[email protected]>
Subject: [postgis-users] Polygon from point query
To: "postgis-users" <[email protected]>
Date: Wednesday, December 29, 2010, 8:49 AM




 


 







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...

 

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.

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.

 

SELECT county_nam FROM county WHERE ?

 

I've been looking at ST_Within() and think the answer lies
with it somehow, thanks for any clues...



 


-----Inline Attachment Follows-----

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to