[postgis-users] using "&&" oprerator

Nicklas Avén nicklas.aven at jordogskog.no
Mon May 10 03:07:48 PDT 2010


Hi Liem

The && operator is not for checking overlapping geometries, just the bounding boxes. The bounding boxes can overlap even if the geometries doesn't. The operator is used to do a first fast (index-based) filtering before doing the real calculation if geometries are overlapping.

To find if the geometries are overlapping you can use a lot of different functions. St_contains as mentioned will work, just get the order right of the arguments. If you use ST_Intersects instead you don't have to bother about the order of arguments because if a intersects b also b intersects a. 

If it is a large dataset be sure to have a spatial index on your geometry columns.

So you query will be something like:

SELECT f.point_id, s.zip_id
FROM points f, zips s
WHERE ST_Intersects(ST_SetSRID(ST_MakePoint(f.longitude, f.latitude),4326), s.zip_polygon);


Hope that helps
Nicklas





http://postgis.org/documentation/manual-1.5/ST_Geometry_Overlap.html

2010-05-10 Edward Mac Gillavry  wrote:

Liem,
>
>You may want to check out http://postgis.refractions.net/documentation/manual-1.4/ST_Contains.html for the ST_Contains function. Hope this helps.
>
>Kind regards,
>
>Edward Mac Gillavry
>
>Date: Mon, 10 May 2010 11:29:27 +0700
>From: liemnguyendl at gmail.com
>To: postgis-users at postgis.refractions.net
>Subject: [postgis-users]  using "&&" oprerator
>
>
>Hi All, i'm a newbie with postgis and probably this is an easy question.
>
>As I know "&&" operator which is used for checking 1 geometry is overlap on another or not.
>Could I check 1 point is overlap on 1 polygon by the query bellow ?
>
>
>
>Cheers.
>-- 
>Liem Nguyen
>Developer
>Axon Active Corp.
>----------------------------------------------------------------------------
>Direct Line      : +84 38 948 4645
>Fax                  : +84 38 811 3489
>Mobile Phone  : +84 168 994 8897
>Skype ID         : liemnguyendl2204
>Email               : liem.nguyen at axonactive.net / liemnguyendl at gmail.com
>Web Site          : axonactive.vn
>Address           : 87 Thang Long Street,Gate 2 Ward 4,
>                          Tan Binh District, HCM city, Vietnam.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100510/47168b28/attachment.html>


More information about the postgis-users mailing list