[postgis-users] Finding polygons outside other polygons

Martin Weinelt mweinelt at planiglobe.com
Mon Mar 8 00:38:47 PST 2010


Hello to all,

in a current project, I am trying to do a bit more serious stuff with PostGIS, 
apart from using it as as a backend for web mapping. 

I could use some tips or guidelines for the follwing - not very complicated - 
task.

I have two tables, one holding some 3000 polygons describing city limits, 
another with some 100000 polygons describing individual houses. 

What I would like to have is another table with all houses outside any city 
limits.

The following function seem to be candidates for this
  ST_Disjoint
  ST_Covers (not)
  ST_Within (not)
  ST_Intersects (not)
  ST_Distance

First thing I did was to put the city polygons into one MultiPolygon (table 
with one row, 'my_cities_multi' ). Then , for the sake of testing this, I 
ran :

select count(a.the_geom) from my_houses as a , my_cities_multi as f
  where   ST_Disjoint( a.the_geom  , f.the_geom ) 

This took some 30 minutes on a 3 GHz, two core machine and ended with:

"NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed 
linestring"

I've checked with ST_IsClosed on both tables, no complains.

I guess my task is a rather common application. But I am not that SQL-savvy. 
May be some one can point me to a best practice with this, also in terms of 
performance.

Thanks,

Martin 



More information about the postgis-users mailing list