Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have lots of Polygons of datatype Geometry in SQL Server 2008. The image below shows how a select of all these Geometrys looks visualized.

Lots of Geometrys

What I need to do is create a Polygon which represents the outer boundary of all these polygons. So I used the response given to a previous spatial question I asked to create the following code:

DECLARE @test TABLE(geom GEOMETRY);

INSERT INTO @test SELECT geom FROM ForceBoundary

DECLARE @geom GEOMETRY
SELECT @geom = (SELECT TOP 1 geom FROM @test)
SELECT @geom = @geom.STUnion(geom) FROM @test

SELECT @geom

This produced the following result, which has cracks in it due to holes between the polygons:

Combined polygons with cracks

So I updated my query with the following change:

INSERT INTO @test SELECT geom.Reduce(0.001).STBuffer(100) FROM ForceBoundary

Which improved the result, however it's not solving the issue completely and it also damages the outer boundary accuracy.

Combined polygons with less cracks

What is the correct way to achieve this? From looking through a list of the STxxxx functions I couldn't see one that seemed to provide the results I need?

I've tried SELECT @geom.STExteriorRing() but it doesn't return anything. Appending it with .STAsText() returns null.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It sounds like you want to remove slivers. There is a function for this in the SQL Server Spatial Tools project - FilterArtifactsGeometry.

A blog post on using the function can be found here.

This has an option for filtering out small poylgons using the ringTolerance parameter:

Remove all polygon rings thinner than provided tolerance (e.g. ring.STArea < ringTolerance x ring.STLength). A value of 0 will not remove any rings.

In practice, this allows very thin polygon rings (slivers) to be detected and removed while leaving more typically shaped polygon rings alone. The presumption is, of course, that slivers are undesirable but non-sliver rings are desirable.

share|improve this answer
    
It seems this SQL Server Spatial Tools library is very useful, I've used it several times now to plug holes in the basic SQL Server 2008 spatial functionality –  Peter Bridger Dec 5 '11 at 13:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.