[postgis-users] clip a polygon layer with another polygon later
Puneet Kishor
punk.kish at gmail.com
Fri Jun 8 19:50:15 PDT 2012
Given
CREATE TABLE outline (
id,
the_geom
);
and
CREATE TABLE polys (
id,
the_geom
);
I want to update polys.the_geom with only those that are clipped by "outline". That is, all the "polys" that are completely within the ouline.the_geom rows should remain intact, all those that are intersected should only have there overlapping portion retained, and all that are outside outline.the_geom should be set to null.
I am unable to figure out how to do this in one query. The following doesn't work
UPDATE polys
SET the_geom = ST_Intersection(o.the_geom, p.the_geom)
FROM outline o JOIN
polys p ON ST_Intersects(o.the_geom, p.the_geom)
WHERE ST_Intersects(o.the_geom, p.the_geom) = 'true';
--
Puneet Kishor
More information about the postgis-users
mailing list