# Adjusting polygons to boundary and filling holes

Here's the problem:

Where:

1: department boundary

3: polygons inside department boundary that "touch" the department boundary(1). They are not necessary fitting well inside

2: holes between 1 and 3

I need to "adjust" polygon shapes (3) to "match" department boundary (1) filling the holes (2)

Using PostGIS:

My 1st approach was to get the st_pointonsurface of all numbers 2 and number 3 by departments. Then assign the holes (2) to the nearest polygon by pointonsurfaces between each other.

See image (from another department boundary but same problem, exceeding dotted lines with no fillcolor are polygons zones that exceeded department boundary that I've already cut off by department boundary so no problem there)

This worked but got me another problem::

• some (lots of) holes (2) that where attached to the nearest polygon (by st_pointonsurface) were really long lines

Here (2) are the holes that were attached to the nearest polygon, and the result is 'strange' new polygons with really long lines.

I can use any of ArcGIS 10, Quantum GIS and PostGIS to solve this, but I can't get a way to solve this.

EDIT

How about using topology? what rules may be useful for this problem?

How topology will resolve when multiple polygons are fighting to get the same hole?

EDIT 2

Using geometry approach with PostGIS.

one idea: - make buffers of the multiple polygons that are inside the department boundary - get the st_intersection between buffered polygon vs original polygon + hole. This way the new "buffered" polygon only keep the buffer where the "hole"-intersected-area is touched.

• This may work with simple examples .. but with real world holes and polygons..
• This will leave us another problem: the overlaps between different buffered polygons inside hole areas..

• Continuing along the PostGIS route, I've had good results assigning holes to polygons based on the longest shared boundary instead of the closest distance based on `ST_PointOnSurface`. If you have really, really long slivers, you might need to add logic to split the sliver polygons if they exceed a certain size. Commented Apr 11, 2014 at 11:10

1. Use ST_DumpPoints to get a set of vertices for each polygon in 3.
2. From that construct Voronoi Polygons around your vertices
3. Dissolve the Voronois by grouping
4. Clip the resulting shapes with your department boundary.

You can use ArcGiS and create topology in your geodatabase. You should to choose one of these rules for polygons (for your shapefiles 1 and 3). Than you will be able to validate topologies and fix all of errors.

• i understand the topology way, also had this way link and this link but i was looking for a geometry way of resolving this. Is there's no geometry way of making this? Commented Apr 3, 2014 at 17:01

After making a topology, check out the Align Edge tool. Click on whichever edge you want moved, and then the edge where you want it to go.

With multiple polygons, stretch the boundary of one, by a single vertex, to the edge you want to align to, and use the same tool. Repeat for the rest of them.

Whoops, didn't notice this was PostGIS, disregard.

• I understand doing this manually but i was lookin for an auto-mode because i got really lots of department boundaries with really lots of multiple polygons inside each department.. Commented Apr 4, 2014 at 14:03