[R-sig-Geo] How to buffer a polygon by area

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu May 29 00:30:11 CEST 2014


Hi Barry,

I think it is guaranteed to converge. The first estimate of the buffer width is the extra area divided by the perimeter. That would be to large in most cases. The adjustments are based on the difference between the target area and the last buffered area and the perimeter of the last buffer. So the buffer width is only updated based on the last errors.

I have tried the examples below. A starlike polygon, a rectangle and a U shape, all very thin. I applied a large buffer (1e6). It takes 11, 12 and 12 steps to converge (precision < 1e-7). With small buffers like 1.1 only a few steps are needed.
The algorithm starts hopping around when the precision < 1e-7). I think that is due to the precision of gBuffer(), gArea() and/or gLength(). On the other hand: a precision of 0.00001% seems acceptable to me.

spgeom <- readWKT("POLYGON((1 0, 10000 10000, 0 1, -10000 10000, -1 0, -10000 -10000, 0 -1, 10000 -10000, 1 0))")
spgeom <- readWKT("POLYGON((0 0, 0 10000, 1 10000, 1 0, 0 0))")
spgeom <- readWKT("POLYGON((0 0, 0 10000, 1 10000, 1 1, 2 1, 2 10000, 3 10000, 3 0, 0 0))")
ratio = 1e6

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey

________________________________________
Van: b.rowlingson at gmail.com [b.rowlingson at gmail.com] namens Barry Rowlingson [b.rowlingson at lancaster.ac.uk]
Verzonden: woensdag 28 mei 2014 18:18
Aan: ONKELINX, Thierry
CC: Julie Lee-Yaw; r-sig-geo at r-project.org
Onderwerp: Re: [R-sig-Geo] How to buffer a polygon by area

On Wed, May 28, 2014 at 3:36 PM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:

>     while(abs(achieved.precision) > precision & steps < maxsteps){
>       buffered.perimeter <- gLength(buffered.spgeom)
>       buffer.width <- buffer.width - achieved.precision * spgeom.area /
> buffered.perimeter
>       buffered.spgeom <- gBuffer(spgeom, width = buffer.width)
>       achieved.precision <- gArea(buffered.spgeom) / spgeom.area - ratio
>       steps <- steps + 1
>     }

Is this guaranteed to converge? Could there be some polygon for which
the buffer width updating step bounces between two values like the
bistable state of an iterated function? Could a concave polygon have a
smaller perimeter for a larger buffer size? I think yes, but I'm not
sure if that would cause this method to not converge anyway...

My binary search is guaranteed to converge since buffer area is
strictly increasing with increasing buffer width...

Barry
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.



More information about the R-sig-Geo mailing list