Skip to content

Commit 18fe573

Browse files
committed
fix @jmhatch 's problem in #1529
1 parent 23a70ad commit 18fe573

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

R/cast_sfc.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ close_polygon_or_multipolygon = function(x, to) {
5454
m = rbind(m, m[1,])
5555
if (nrow(m) < 4)
5656
stop("polygons require at least 4 points")
57-
m
57+
unclass(m)
5858
}
5959
add_attributes(
6060
if (to_col == 2)
@@ -168,9 +168,10 @@ st_cast.sfc = function(x, to, ..., ids = seq_along(x), group_or_split = TRUE) {
168168
stop("use smaller steps for st_cast; first cast to MULTILINESTRING or POLYGON?")
169169
} else if (from_col < to_col) { # "horizontal", to the right: group
170170
ret = if (from_col == 0)
171-
lapply(unname(split(x, ids)), function(y) structure(do.call(rbind, y), class = class(x[[1]])))
172-
else
173-
lapply(unname(split(x, ids)), function(y) structure(y, class = class(x[[1]])))
171+
lapply(unname(split(x, ids)), function(y) structure(do.call(rbind, y),
172+
class = class(x[[1]])))
173+
else
174+
lapply(unname(split(x, ids)), function(y) structure(y, class = class(x[[1]])))
174175
ret = copy_sfc_attributes_from(x, ret)
175176
reclass(ret, to, need_close(to))
176177
} else if (from_col == 3 && to == "MULTILINESTRING") {

0 commit comments

Comments
 (0)