[postgis-users] Counting intersecting polygons

Arnaud L. arnaud.listes at codata.eu
Mon May 27 04:05:35 PDT 2019


Le 27/05/2019 à 12:57, Sarthak Vijay a écrit :
> I have 2 tables containing polygons in same general area. What I want is 
> the count of polygons in the first table (Table_1, represented by 
> purple) that intersect with polygons in the 2nd (Table_2, represented by 
> green).

Hi, do you mean the number of polygons in Table_1 that intersect with at 
least one polygon of Table_2 ?

If yes, then I would do it like this :

SELECT COUNT(*) FROM Table_1 WHERE EXISTS (SELECT 1 FROM Table_2 WHERE 
ST_Intersects(Table_1.wkb_geometry, Table_2.wkb_geometry));


Cheers
--
Arnaud


More information about the postgis-users mailing list