terra icon indicating copy to clipboard operation
terra copied to clipboard

Overhead in `buffer()`

Open kadyb opened this issue 3 years ago • 0 comments

This is nothing important, but comparing the terra::buffer() with the geos::geos_buffer() we can see the difference in performance, which can probably be reduced.

library("geos")
library("terra")

n = 50000
x = rnorm(n) * 100
y = rnorm(n) * 100

pts1 = vect(data.frame(x, y), geom = c("x", "y"), crs = "epsg:2180")
pts2 = geos_make_point(x, y, crs = crs(pts1))

t = bench::mark(
  terra = buffer(pts1, 10, quadsegs = 30),
  geos = geos_buffer(pts2, 10, params = geos_buffer_params(quad_segs = 30)),
  iterations = 10, check = FALSE
)
t[, 1:5]
#>   expression      min   median `itr/sec` mem_alloc
#> 1 terra         3.14s    3.22s     0.307      680B
#> 2 geos          1.79s    1.82s     0.546    2.69MB

kadyb avatar Jul 05 '22 19:07 kadyb