Buffer on line create multipolygon
If you do the following:
Code BlockDECLARE @line Geography
SET @line = Geography::STGeomFromText('LINESTRING(-34 150, 34 -120, 34 -130)',4326);
SELECT @line.STBuffer(1);
you will get back an 8-part MultiPolygon:Code BlockMULTIPOLYGON (((33.999966688576258 -130.00001183443254, 34.074030834715067 -127.59532797110113, 34.1013716857137 -125.00002730913887, 34.074082415921566 -127.59523166186089, 34.000044537461591 -130.0000049591942, 33.999966688576258 -130.00001183443254)), ((28.805105091752665 -129.79917723576583, 31.495776183614385 -125.03555555298253, 34.000018032228937 -120.00002037372069, 31.49587757741903 -125.03563169984618, 28.805105091752665 -129.79917723576583)), ((13.438931848003461 -150.49287518101377, 16.695412620518191 -146.67396209015817, 19.879581608571691 -142.72417848347527, 16.695517235640406 -146.67395905428674, 13.438931848003461 -150.49287518101377)), ((6.7731436308048938 -157.8476585193437, 10.126432232286826 -154.20843827903912, 13.438931848003461 -150.49287518101377, 10.126542413170654 -154.20854764393184, 6.7731436308048938 -157.8476585193437)), ((-10.126473119896616 -175.79153478476439, -6.7731576849050663 -172.15229414599341, -3.3931807991888809 -168.5636115170775, -6.7731547590581167 -172.15239430604888, -10.126473119896616 -175.79153478476439)), ((-16.695433132442009 176.67401946488724, -13.439000278472005 -179.50708771515804, -10.126473119896616 -175.79153478476439, -13.438904030725054 -179.50718312301061, -16.695433132442009 176.67401946488724)), ((-25.955738795465631 164.31603968650759, -22.97306644659572 168.61462769111407, -19.879526597842744 172.72412960070821, -22.972999299101133 168.61462132687637, -25.955738795465631 164.31603968650759)), ((-34.000002264228755 149.99997786468589, -34.000022930118313 150.00001287724459, -31.495843856590419 155.03559321306511, -28.805063419821849 159.79912884955866, -31.495799900050041 155.0355866894337, -33.999986583877352 150.000006725428, -34.000002264228755 149.99997786468589)))This polygon looks like a dashed "line" from start to end.
Why is that?
If you remove the last point in the line, the returned result looks much more correct.
Answers
This is because of the Default tolerance used with STBuffer. The resultant geography is quite large and will only be two meters across. The default tolerance value is absolute and does not depend on the size of the geography, so for this case it is very low and the geography is so thin that the calculated geography is determined to be degenerate in a few places and collapses to empty, which explains the dashed-line behavior you see.
You can get the behavior you want even with such a small buffer distance if you use the BufferWithTolerance method instead, with a tolerance that is relative to the size of your geography:
DECLARE @line Geography
SET @line = Geography:
TGeomFromText('LINESTRING(-34 150, 34 -120, 34 -130)',4326);
SELECT @line.BufferWithTolerance(1, .001, 1);
All Replies
This is because of the Default tolerance used with STBuffer. The resultant geography is quite large and will only be two meters across. The default tolerance value is absolute and does not depend on the size of the geography, so for this case it is very low and the geography is so thin that the calculated geography is determined to be degenerate in a few places and collapses to empty, which explains the dashed-line behavior you see.
You can get the behavior you want even with such a small buffer distance if you use the BufferWithTolerance method instead, with a tolerance that is relative to the size of your geography:
DECLARE @line Geography
SET @line = Geography:
TGeomFromText('LINESTRING(-34 150, 34 -120, 34 -130)',4326);
SELECT @line.BufferWithTolerance(1, .001, 1);- For those reading this in the Future, I just wanted to comment here as well that this behavior has changed in the February CTP. The outcome of the Buffer call is now a GeometryCollection, containing all the Polygons in the MultiPolygon output above with LineStrings connecting them in the segments that had previously been collapsed to empty. This prevents the original dashed-line appearance on the map. This change, along with the others made in the February CTP, are described in Ed's blog post: http://blogs.msdn.com/edkatibah/archive/2008/02/28/new-spatial-features-in-the-february-ctp-ctp-6.aspx


