+1  A: 

Wow, that's a pretty cool set of features.

Taking a look at some of the other methods available, here are a few ideas that come to mind:

On the unreduced shapes, use .STIntersects (returns a boolean) and .STIntersection (returns a shape) to find out if and where two shapes intersect.

For two adjacent map regions, I would assume that .STIntersection should return the line segment that borders both.

Then you can reduce these line segments and re-assemble the reduced shapes.

BradC
Yes, I guess that STIntersection would be part of the solution. Also, taking STBoundary of A and intersecting it with B gives the shared border.
Teun D
+1  A: 

I'm not sure how you'd get the "shared" LineStrings from your shapes. Secondly, once you reduce a "subset" of the shape since your endpoints may move from the original and you will not be able to make them match up after reduction.

The nutshell of what I would do is basically use boolean operations to play with the reduced shapes.

First, do what you do, namely create a temporary table of reduced shapes (called #ReducedShapes).

Then, I would create a second temp table and find the areas of overlap (using STIntersection) between all shapes. In this table, I would basically have columns naam1, naam2 and intsec, the last one being of type shape. Something like (untested):

INSERT INTO #IntSecs(naam1, naam2, intsec)
SELECT s1.naam, s2.naam, s1.naam.STIntersection(s2.naam)
FROM #ReducedShapes s1, #ReducedShapes s2 
WHERE s1.naam.STIntersection(s2.naam) IS NOT NULL

This gets you a list of where pairs of shapes overlap. In fact, you have two rows for each overlap. For example, if A and B overlap you'd have and . I would make a pass and delete one of the two for each occurence.

Lastly, for each overlap, I would subtract (STDifference) the intersection from only one of the two regions in the pair from the #ReducedShapes table. Imagine you have two squares A and B, half-overlapping. The operation would involve A.STDifference(B) meaning you keep all of B and half of A. I would insert the modified shapes into a third table (say #ModifiedShapes).

Two problems: a) as you can see from your "orange" and "blue" shapes, they did not reduce similarly, so you'll get one of two possible reductions depending on how you deal with who "wins". b) a more complicated form of the problem is that, depending on the complexity of the initial shapes, you may get overlap between three or more regions. You'll have to determine your own way to establish which one shape "wins" in that intersection, based on your particular needs. It's not clear if there are constraints. Could be as simple as arbitrarily picking a winner by ordering, or more complicated since accuracy is important.

The above concept unfortunately does not address the issue of gaps. This one's a little more complicated and I am not 100% sure how to resolve it. But, if you create a third table that subtracts (STDifference again) all the modified shapes #ModifiedShapes from all the original shapes in #Shapes (testing for overlap before actually subtracting, of course), you'd be left with the remainder shapes in the gaps. You'd want to aggregate the adjoining shapes and assign a "winning color", possibly merging it back in with the related shape.

This answer is long and I will leave it like this. I may be barking up the wrong tree. Based on your feedback/questions, I would add to the post.

alphadogg
Thanks for these ideas. A different approach from what I had in mind. Very interesting. The problems with gaps and multiple overlaps are serious though. I think that "more than double overlaps" can be solved by adding the overlap always to the lowest ID shape. Gapsseems tougher.
Teun D
Overlaps are hard because there are multiple ways to address them. But, I didn't know what your needs were. The easiest is to let one region win.
alphadogg
And, yes, gaps are much, much harder. The idea is to end up with a set of shapes for each gap, assign each one a color of a neighboring region and then merge it into that region. Not exactly sure how...
alphadogg
Maybe found it? Consider STInteriorRingN() on the STUnion() of all modded shapes. It should give you a GeomCollection of gaps. Then, armed with this list, find the areas in the gap from the original, unreduced shapes and pick a winner for each gap.
alphadogg
http://jasonfollas.com/blog/archive/2008/04/03/sql-server-2008-spatial-data-part-4.aspx
alphadogg
Yes, that could work. Although a gap might be "open ended". Haveing no bordering polygon on on side. There is no such case in the sample shown, but it could happen.
Teun D
Actually, I think we've establsihed how to handle overlaps of reduced shapes. Now, you want to take care of the gaps inside your reduced shapes. If there is an "open gap", like a bay or indentation, then you don't really have to worry about it since it would stay as-is.
alphadogg
What could happen is that some inside gap is near the edge, such that it looks enclosed but isn't. Then, you'd have a bad inside shape. This would depend on your geo data's quality...
alphadogg
A: 

An older question I know, but...

Isaac is right that you could reduce the features to lines, and use them as shared boundaries.

But the software he mentions - FME - has a transformer called the Generalizer which will simplify them as you wish while still retaining them as polygons. The option to use is called 'Preserve Shared Boundaries'. You can download FME from here and request a 14-day eval license to try it out.

Cheers

Mark

Mark Ireland | FME Evangelist Safe Software Inc.

Mark I