[postgis-users] ST_Buffer returning multipolygons
Martin Davis
mtnclimb at telus.net
Fri Jan 18 21:09:50 PST 2013
Buffers of single LineStrings should NEVER produce a polygon with more
than one component. So this issue was puzzling - until the test data
and images were posted. They reveal that the problem is a robustness
error deep inside the JTS/GEOS buffer code (the problem shows up
identically in JTS as well).
A quick fix is to add a post-computation filter which keeps only the
largest polygon component in situations where single polygons are
expected (i.e. buffers of points, single linestrings, and positive
buffers of single polygons). This can be done externally - and ideally
it should be built into the JTS/GEOS buffer code (as a temporary hack,
against the day when the basic algorithm can be improved to eliminate
the problem).
(Cross-posting to GEOS list as well).
On 1/18/2013 9:40 AM, marquz74 wrote:
> Stephen Woodbridge wrote
>> On 1/18/2013 11:10 AM, marquz74 wrote:
>>> Francois Hugues wrote
>>>> We don't know what are your original geometries or what kind of buffer
>>>> you apply (since you work with linestrings we can assume it is a
>>>> positive buffer). Maybe some of your linestrings are multilinestrings
>>>> with disjoint components.
>>> the query:
>>>
>>> SELECT GeometryType(the_geom)
>>> FROM streams
>>> WHERE GeometryType(the_geom) <> 'LINESTRING';
>>>
>>> returns 0 records.
>> If you have a linestring that follows a stream or rivier then you likely
>> will have an ox bow like geometry, think of the letter Omega. If you add
>> enough buffer to this you will end up intersecting your buffer with
>> another part of the buffer. This creates polygon or multipolygon.
>>
>> You could post you command and geometry so others can look at it.
>>
>> select gid, astext(the_geom) from streams where
>> GeometryType(st_buffer(the_geom,
>> <distance>
>> )) = 'MULTIPOLYGON';
> Ok. I have a totale of 8554 streams (LINESTRINGs).
> With the query
>
> SELECT gid, AsText(the_geom) FROM streams
> WHERE GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';
>
> I get 11 records as MULTIPOLYGONs
>
> The first record is:
>
> 674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913
> 216785.560172686,640770.475488952 216786.226162019,640770.647396495
> 216787.800152365,640770.658978918 216789.268376902,640770.447752096
> 216792.399898366,640769.98018796 216795.624688816,640769.110287021
> 216798.527305023,640767.648768098 216801.891389348,640766.02448565
> 216804.805892778,640764.74005588 216807.134569434,640763.337363474
> 216809.560477487,640761.650901703 216812.246990061,640759.955600712
> 216815.327305019,640758.482499366 216817.868732504,640757.383693167
> 216819.548488661,640756.238862077 216821.226720821,640754.01503683
> 216824.434442434,640751.366929134 216828.435255234,640749.204368809
> 216832.450088865,640747.25516891 216836.227787618,640746.014020829
> 216838.801219168,640745.393751588 216840.360274284,640744.315976633
> 216842.854457673,640743.400050801 216844.65704848,640742.582575565
> 216846.277673322,640741.52491745 216848.478638524,640740.503835408
> 216850.705816576,640739.787553975 216852.270967708,640739.053289307
> 216853.851968469,640738.173025147 216855.546355058,640737.55488951
> 216856.568961104,640736.817272035 216857.822910812,640735.910795021
> 216859.35697228,640734.77510795 216861.236982439,640733.832969266
> 216862.938074642,640732.814325629 216865.039674844,640731.225095251
> 216869.012141189,640729.979984761 216871.879095724,640729.445974092
> 216873.02148841,640729.002794006 216873.679857725,640728.952197105
> 216873.745389857,640728.676962154 216874.089814544)
>
> I isolated the stream and the related buffer, you can see large and small
> zoom at this links:
> https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
> https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit
>
> Thank you for your patience :-)
>
> Marco
>
>
>
> --
> View this message in context: http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002333p5002345.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
More information about the postgis-users
mailing list