Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: how to chec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 3454 of 3631
Post > Topic >>

Re: how to check if a point is contained in a polygon ?

by dev@[EMAIL PROTECTED] (Richard Huxton) May 7, 2008 at 03:38 PM

Julien Cigar wrote:
> Hello,
> 
> I'm busy to work on an application where the user can select (with
> precision) an area on a map (for example the contours of a lake) and I
> have to retrieve all the data (specimen observations) within this area. 
> 
> I have a list of coordinates pair [(lat1, long1), (lat2, long2), (lat3,
> long3), (..., ...)] which form a polygon. In my database every specimen
> has a pair of coordinates where it has been collected.

Are you familiar with the PostGIS project - if you're doing a lot of 
this, it might be worthwhile looking into.

http://www.postgis.org/

> Is there an SQL function to check if a point is contained in a polygon
> shape (before I start to write my own) ?
> 
> I tried something like :
> 
> rodentia=> select point '(-8,25)' <@[EMAIL PROTECTED]
 polygon
> '((-3,10),(8,18),(-3,30),(-10,20))';

Works both ways around here:

SELECT point '(-8,25)' <@[EMAIL PROTECTED]
 polygon '((-3,10),(8,18),(-3,30),(-10,20))';

SELECT polygon '((-3,10),(8,18),(-3,30),(-10,20))' @[EMAIL PROTECTED]
> point '(-8,25)';

I'm running 8.3, but it seems to be in 8.2 too.

Try \do '<@[EMAIL PROTECTED]
' from psql to see what operators are available.

-- 
   Richard Huxton
   Archonet Ltd

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 4 Posts in Topic:
how to check if a point is contained in a polygon ?
jcigar@[EMAIL PROTECTED]   2008-05-07 18:25:36 
Re: how to check if a point is contained in a polygon ?
dev@[EMAIL PROTECTED] (R  2008-05-07 15:38:17 
Re: how to check if a point is contained in a polygon ?
jcigar@[EMAIL PROTECTED]   2008-05-07 19:00:23 
Re: how to check if a point is contained in a polygon ?
tgl@[EMAIL PROTECTED] (T  2008-05-07 11:12:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 22:55:06 CDT 2008.