dcooley / sfheaders

Build sf objects from R and Rcpp
https://dcooley.github.io/sfheaders/
Other
74 stars 5 forks source link

sf_bboxes() #77

Closed dcooley closed 4 years ago

dcooley commented 4 years ago

As well as (re)-calculating the whole, also have a function which calculates the bbox of every geometry and returns it as an sf / sfc object

TODO

benchmark


library(microbenchmark)

microbenchmark(

  sfh = { sfheaders::sf_boxes( mapdeck::roads ) },
  geo = { geovctrs::geo_envelope( mapdeck::roads ) },
  base = { do.call(rbind, lapply(st_geometry(mapdeck::roads), st_bbox)) },
  times = 5

)

# Unit: milliseconds
# expr       min        lq      mean   median        uq       max neval
#  sfh  59.74507  61.73744  66.79104  64.0278  74.08454  74.36036     5
#  geo 248.43113 270.91250 302.89493 314.5541 329.51862 351.05831     5
# base 463.71125 499.81002 524.54896 519.0344 562.72610 577.46298     5