[postgis-users] ST_Buffer() never returns

Martin Davis mbdavis at refractions.net
Wed Sep 24 09:41:27 PDT 2008


Cool, that's very useful feedback.   This would be worth capturing in 
the PG wiki...

Andi Vajda wrote:
>
>
> On Sep 24, 2008, at 8:45, Martin Davis <mbdavis at refractions.net> wrote:
>
>> Wow!  It's great that this works for you - and I'm happy that you are 
>> able to use the word "fast" as well!
>>
>> I would have expected that say 3 levels of buffering would have been 
>> sufficient.  Did you try that first, and found you had to move to 
>> more levels?
>
> I first went with two levels: 0.0001 and 0.1. While it worked, it took 
> several minutes for some shapes. Inserting the 0.001 and 0.01 levels 
> made it all much much faster. I could then update all 2654 shapes in 
> question in about a
> minute or two.
>
> Andi..
>
>>
>>
>> Martin
>>
>> Andi Vajda wrote:
>>>
>>> On Fri, 12 Sep 2008, Martin Davis wrote:
>>>
>>>> This is an example of a known issue with GEOS/JTS buffering.  The 
>>>> problem occurs when using a relatively large buffer distance on 
>>>> geometries which have a large number of vertices which are 
>>>> relatively dense (i.e. the distance between adjacent vertices is 
>>>> much smaller than the requested buffer distance).
>>>>
>>>> A couple of ways to avoid this problem are:
>>>> - simplify the input geometry using a tolerance which gets rid of 
>>>> most of the very dense vertices (use a tolerance of say from 1% to 
>>>> 10% of the buffer distance)
>>>> - buffer the geometry mulitple times, starting with a very small 
>>>> buffer distance and gradually increasing it
>>>
>>> Thanks, with your tip, I defined the following function which made 
>>> it work (and fast) for all the shapes in my db:
>>>
>>> CREATE OR REPLACE FUNCTION gix_make_shell(geometry)
>>> RETURNS geometry AS $$
>>>    SELECT 
>>> ST_Simplify(ST_Buffer(ST_Simplify(ST_Buffer(ST_Simplify(ST_Buffer(ST_Simplify(ST_Buffer($1, 
>>> 0.0001), 0.0001), 0.001), 0.001), 0.01), 0.01), 0.1), 0.1)
>>> $$ LANGUAGE SQL STABLE;
>>>
>>> Andi..
>>>
>>
>> -- 
>> Martin Davis
>> Senior Technical Architect
>> Refractions Research, Inc.
>> (250) 383-3022
>>
>

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list