title: How to separate a multipolygon geometry into several polygons objects after performing a st_union() operation?
body: <p>I have a set of polygons of which some intersect and/or touch (common borders). I am using R's <code>sf</code>package to perform operations on polygons. My approach so far was to use <code>sf::st_union()</code> which joins neighboring and intersecting polygons as i want, but it also combines all polygons into a  <code>MULTIPOLYGON</code>geometry. I would like to have each polygon separated as a sf(data.frame) class where each polygon object is show as a row in the <code>data.frame</code></p>
  
  <p>I show below an example. I start by creating an example dataset:</p>
  
  <pre><code>    # Creating four example polygons, of which two (two squares) are neighbors:
  
      p1 &lt;- rbind(c(0,0), c(1,0), c(3,2), c(2,4), c(1,4), c(0,0))
      pol1 &lt;-st_polygon(list(p1))
      p2 &lt;- rbind(c(3,0), c(4,0), c(4,1), c(3,1), c(3,0))
      pol2 &lt;-st_polygon(list(p2))
      p3 &lt;- rbind(c(4,0), c(4,1), c(5,1), c(5,0),c(4,0))
      pol3 &lt;-st_polygon(list(p3))
      p4 &lt;- rbind(c(3,3), c(4,2), c(4,3), c(3,3))
      pol4 &lt;-st_polygon(list(p4))
  
      d = data.frame(some_attribute = 1:4)
      d$geometry = st_sfc(pol1,pol2,pol3,pol4)
      df = st_as_sf(d)
  
      class(df)
      #[1] "sf"         "data.frame"
  
      df
      # Simple feature collection with 4 features and 1 field
      # geometry type:  POLYGON
      # dimension:      XY
      # bbox:           xmin: 0 ymin: 0 xmax: 5 ymax: 4
      # epsg (SRID):    NA
      # proj4string:    NA
      # some_attribute                       geometry
      # 1              1 POLYGON((0 0, 1 0, 3 2, 2 4...
      # 2              2 POLYGON((3 0, 4 0, 4 1, 3 1...
      # 3              3 POLYGON((4 0, 4 1, 5 1, 5 0...
      # 4              4 POLYGON((3 3, 4 2, 4 3, 3 3))
  </code></pre>
  
  <p><code>plot(df)</code> gives:</p>
  
  <p><a href="https://i.stack.imgur.com/Uky7r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Uky7r.png" alt="plot(df)"></a></p>
  
  <p>I then perform a <code>st_union()</code> operation to combine all polygon geometries that intersect or touch (the two squares above) into one:</p>
  
  <pre><code>    df_union &lt;- df %&gt;% st_union() 
      df_union
      # Geometry set for 1 feature 
      # geometry type:  MULTIPOLYGON
      # dimension:      XY
      # bbox:           xmin: 0 ymin: 0 xmax: 5 ymax: 4
      # epsg (SRID):    NA
      # proj4string:    NA
      # MULTIPOLYGON(((3 3, 4 3, 4 2, 3 3)), ((4 0, 3 0...
  </code></pre>
  
  <p><code>plot(df_union)</code> results in:</p>
  
  <p><a href="https://i.stack.imgur.com/w1gdl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/w1gdl.png" alt="plot(df_union)"></a></p>
  
  <p>As shown above the result of <code>df_union</code> is a <code>MULTIPOLYGON</code> geometry with one row only. I would like to perform an operation that separates each polygon into a geometry as shown in the figure above, but resulting in several polygon objects, something equivalent to this:</p>
  
  <pre><code>    # Simple feature collection with 4 features and 1 field
      # geometry type:  MULTIPOLYGON
      # dimension:      XY
      # bbox:           xmin: 0 ymin: 0 xmax: 5 ymax: 4
      # epsg (SRID):    NA
      # proj4string:    NA
      # some_attribute                       geometry
      # 1              1 POLYGON((0 0, 1 0, 3 2, 2 4...
      # 2              2 POLYGON((3 0, 4 0, 5 1, 5 0...
      # 3              3  POLYGON((3 3, 4 2, 4 3, 3 3))
  </code></pre>
  
  <p>How can i do this using the <code>sf</code> package?</p>