Did you try:

select powerplants.gid, plantname
  from powerplants, pca_huc
 where state = 'CA'
       AND NOT st_contains(pca_huc.geom,powerplants.geom)
 order by powerplants.gid;

This should give you all power plants in CA and not in your contains clause. What is the coverage of pca_huc table? If this covers all of CA then there is not possible result. The would be like say where a=1 and not a=1.

-Steve W

On 9/29/2011 1:21 PM, Vishal Mehta wrote:
I have a point layer and a polygon layer. How do I select points that
are NOT contained within polygons?

For example, this query correctly selects points contained by polygons

--

select powerplants.gid, plantname

from powerplants, pca_huc

where state = 'CA'

AND

st_contains(pca_huc.geom,powerplants.geom)

order by powerplants.gid;

--

I tried to get the inverse selection using st_disjoint instead of
st_contains , but that did not work. I also tried using NOT and EXCEPT
without success (although I may not have constructed the latter queries
correctly..)

Thanks!

Vishal

//

//



_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to