Skip to content

Commit

Permalink
speed up st_combine
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Dec 13, 2022
1 parent d9c5de0 commit 7210201
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/geom-transformers.R
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,11 @@ st_segmentize.sf = function(x, dfMaxLength, ...) {
#' st_combine(nc)
st_combine = function(x) {
x = st_geometry(x)
if (inherits(x, "sfc_POINT") && !is.null(attr(x, "points")))
x = x[]
st_sfc(do.call(c, x), crs = st_crs(x)) # flatten/merge
if (inherits(x, "sfc_POINT") && !is.null(pts <- attr(x, "points"))) {
mp = structure(list(st_multipoint(pts, attr(x, "point_dim"))), bbox = st_bbox(x))
st_sfc(mp, crs = st_crs(x))
} else
st_sfc(do.call(c, x), crs = st_crs(x)) # flatten/merge
}

# x: object of class sf
Expand Down

0 comments on commit 7210201

Please sign in to comment.