Skip to content

Commit f804581

Browse files
committed
fixes #2320
1 parent d7c0112 commit f804581

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# version 1.0-16
22

3+
* `[.sfc` works when setting argument `op`; #2320
4+
35
* `st_sample` for polygons is sensitive to setting `oriented = TRUE` to prevent wrongly correcting ring directions; #2308
46

57
* add support for the GDAL `footprint` utility (requiring GDAL >= 3.8.0) to `gdal_utils`; #2305, by @goergen95

R/sfc.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@ st_sfc = function(..., crs = NA_crs_, precision = 0.0, check_ring_dir = FALSE, d
143143
"[.sfc" = function(x, i, j, ..., op = st_intersects) {
144144
if (!missing(i) && (inherits(i, "sf") || inherits(i, "sfc") || inherits(i, "sfg")))
145145
i = lengths(op(x, i, ...)) != 0
146-
st_sfc(NextMethod(), crs = st_crs(x), precision = st_precision(x),
147-
dim = if(length(x)) class(x[[1]])[1] else "XY")
146+
precision = st_precision(x)
147+
crs = st_crs(x)
148+
dim = if (length(x)) class(x[[1]])[1] else "XY"
149+
x = unclass(x)[i] # now a list
150+
st_sfc(x, crs = crs, precision = precision, dim = dim)
148151
}
149152

150153

0 commit comments

Comments
 (0)