The documentation of the st_union
function of sf
is not clear (for me!) on one point: what are the action and result of the function when applied to an sfc
with a single feature, with the parameter by_feature=FALSE
(default)? It seems that, according to the text of the documentation, nothing should happen and that the value returned should be the same as the one-feature sfc
provided.
I ask this question because it is rather common to find proposals, advice for chaining st_union
to st_combine
, especially in the context of the use of st_difference
(see the sf
manual, at geos_binary_ops
, or ?st_intersection
):
the use of st_difference(SF1,st_union(st_combine(SF2)))
is proposed.
Two questions in order to understand:
Because
st_combine
returns a single-featuresfc
, how couldst_union
have any effect on such an object?Is there any simple case, any example, where
st_union
, withby_feature=FALSE
, applied to a singlesfc
has any effect?
Extract of the documentation of st_union
:
If
st_union
is called with a single argument, x, and by_feature is FALSE all geometries are unioned together and ansfg
or single-geometrysfc
object is returned. Ifby_feature
is TRUE each feature geometry is unioned. This can for instance be used to resolve internal boundaries after polygons were combined usingst_combine
.