@@ -182,6 +182,9 @@ st_boundary.sf = function(x) {
182
182
# ' nc_g = st_geometry(nc)
183
183
# ' plot(st_convex_hull(nc_g))
184
184
# ' plot(nc_g, border = grey(.5), add = TRUE)
185
+ # ' pt = st_combine(st_sfc(st_point(c(0,80)), st_point(c(120,80)), st_point(c(240,80))))
186
+ # ' st_convex_hull(pt) # R2
187
+ # ' st_convex_hull(st_set_crs(pt, 'OGC:CRS84')) # S2
185
188
st_convex_hull = function (x )
186
189
UseMethod(" st_convex_hull" )
187
190
@@ -190,8 +193,12 @@ st_convex_hull.sfg = function(x)
190
193
get_first_sfg(st_convex_hull(st_sfc(x )))
191
194
192
195
# ' @export
193
- st_convex_hull.sfc = function (x )
194
- st_sfc(CPL_geos_op(" convex_hull" , x , numeric (0 ), integer(0 ), numeric (0 ), logical (0 )))
196
+ st_convex_hull.sfc = function (x ) {
197
+ if (isTRUE(st_is_longlat(x )) && sf_use_s2())
198
+ st_as_sfc(s2 :: s2_convex_hull(x ), crs = st_crs(x ))
199
+ else
200
+ st_sfc(CPL_geos_op(" convex_hull" , x , numeric (0 ), integer(0 ), numeric (0 ), logical (0 )))
201
+ }
195
202
196
203
# ' @export
197
204
st_convex_hull.sf = function (x ) {
0 commit comments