[postgis] How can I find which points are contained in a polygon?
Dave Blasby
dblasby at refractions.net
Tue Oct 30 09:28:45 PST 2001
gregoryliapis at yahoo.gr wrote:
> PostgreSQL. My problem is that I need a query to find which cities
> (points) are contained in a specific country (polygon).
Right now, the best way to do this is with the distance() function.
SELECT * FROM <table> WHERE distance(<geom column>,<polygon>) = 0;
OR, to also use the index as well;
SELECT * FROM <table> WHERE distance(<geom column>,<polygon>) =0 AND
<geom column> && BOX3D(<polygon>);
distance(point,polygon) will return 0 if the point is inside the
polygon. If its right on the boundary it will either return 0 or a very
small number (due to precision).
dave
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get your FREE VeriSign guide to security solutions for your web site: encrypting transactions, securing intranets, and more!
http://us.click.yahoo.com/UnN2wB/m5_CAA/yigFAA/PhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the postgis-users
mailing list