Created
November 9, 2018 20:21
-
-
Save mdiener21/046f0a5a4c2365b43097dc9c18cd7c3e to your computer and use it in GitHub Desktop.
Postgis select polygons that are inside and not touching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT c.cadaster_id, r.name | |
, CASE | |
WHEN ST_CoveredBy(c.geom, r.geom) | |
THEN c.geom | |
ELSE | |
ST_Multi( | |
ST_Intersection(c.geom,r.geom) | |
) END AS geom | |
FROM cadaster AS c | |
INNER JOIN roads_ply AS r | |
ON (ST_Intersects(c.geom, r.geom) | |
AND NOT ST_Touches(c.geom, r.geom) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment