[postgis-users] How to Delete Records Outside a Polygon?

Bill Thoen bthoen at gisnet.com
Mon Sep 4 14:12:50 PDT 2006


I'm trying to reduce a collection of farm fields to only those that fall 
within a county border and so I'm trying to figure out the SQL to delete 
all records in one table whose polygons fall outside a particular 
polygon in another table. For example, I've got farms (farm_id integer, 
the_geom geometry) and I've got counties (fips varchar(5), the_geom 
geometry). I want to remove everything from farms only where not 
intersects(farms.the_geom, counties.the_geom) and counties.fips='17001'. 
Unfortunately the pareser doesn't understand my dog-SQL, and I don't 
know how to say it properly. Is there a way I can do this in one SQL 
statement?

- Bill Thoen




More information about the postgis-users mailing list