Skip to content

Instantly share code, notes, and snippets.

View ThierryO's full-sized avatar

Thierry Onkelinx ThierryO

View GitHub Profile
@ThierryO
ThierryO / abuff.R
Last active August 29, 2015 14:01 — forked from barryrowlingson/abuff.R
abuff <- function(spgeom, ratio = 1.1, precision = 0.00001, maxsteps = 20){
require(rgeos)
spgeom.area <- gArea(spgeom)
spgeom.perimeter <- gLength(spgeom)
buffer.width <- (ratio - 1) * spgeom.area / spgeom.perimeter
buffered.spgeom <- gBuffer(spgeom, width = buffer.width)
achieved.precision <- gArea(buffered.spgeom) / spgeom.area - ratio
steps <- 1