This question already has an answer here:

I have two polygons in PostGIS that have incongruities. One polygon (the yellow one) is legal county boundaries. The other polygon (blue) is essentially neighborhoods. 98% of the lines align perfectly. The other 2% don't align because the boundaries have changes but not been updated on the neighborhoods polygon.

My question: Using either PostGIS (preferred) or QGIS, how can I "snap" the neighborhood boundaries to the county boundaries? I've tried:

ST_Multi( ST_Intersection(neighborhoods.geom, county.geom) ) END AS geom

EDIT: This query "worked" in that it prevented neighborhoods from bleeding into incorrect counties, but it just removes the area that causes the bleed creating blank spaces inbetween boundaries.


marked as duplicate by PolyGeo Aug 6 '17 at 9:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I would love to see anyone with a postgis solution as well. – tilt Aug 6 '17 at 16:58
  • For those who arrived here seeking a PostGIS solution, here's what I've arrived at: SELECT b.block, p.county_name, p.district_id ST_AREA(CASE WHEN ST_CoveredBy(b.geom, p.geom) THEN p.geom ELSE ST_Multi(ST_Intersection(b.geom, p.geom)) END) AS geom FROM blocks b INNER JOIN district p ON (ST_Intersects(b.geom, p.geom) AND NOT ST_Touches(b.geom,p.geom)) From there, I ranked the area column, accepted the top ranked area, and forced a p.county_name=b.county_name match. This is not an ideal solution because it's highly specific to my use case, but may provide help to others. – LearnWorkLearn Aug 28 '17 at 15:31