[postgis-users] Counting intersecting polygons

Marcin Mionskowski mionskowskimarcin at gmail.com
Mon May 27 05:47:16 PDT 2019


Or simpler:

SELECT COUNT(DISTINCT t1.column_with_unique_ids)
FROM Table_1 t1
	,Table_2 t2
WHERE ST_Intersects(t1.wkb_geometry,t2.wkb_geometry)

Greetings,
Marcin

W dniu pon, 27.05.2019 o godzinie 13∶05 +0200, użytkownik Arnaud L.
napisał:
> 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
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list