Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Created November 9, 2018 20:21
Show Gist options
  • Save mdiener21/046f0a5a4c2365b43097dc9c18cd7c3e to your computer and use it in GitHub Desktop.
Save mdiener21/046f0a5a4c2365b43097dc9c18cd7c3e to your computer and use it in GitHub Desktop.
Postgis select polygons that are inside and not touching
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