2

I have 2 layers that I want to compare. I wish to retrieve the features in the layer 1 that have no part in common with the features in the layer 2. I try queries like that but do not returns me the expected result :

select * from c1 join activite.c2 
on st_disjoint(c1.geom, c2.geom) 
WHERE c2 blabla' ;

I get here (except error) a table that lists for each feature in the layer 1 those of layer 2 who do not cut it. But how to recover those of layer 1 which are intersected by any of the layer 2 ? Hope it s clear...

1

I found an answer with a count & group by:

select c.gid, c.*, count(c.gid) from c1 
join c2
on st_disjoint(c1.geom, c2.geom)
WHERE c2.nom_comm ILIKE 'blabla'
GROUP BY c.gid
having count(c.gid) >22 ;

22 means disjoint with all features of c2.

  • 2
    be aware that st_disjoint does not use spatial indexes. – nickves Jun 19 '15 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.