Make a union of polygons in GeoPandas, or Shapely (into a single geometry)
<p>I am trying to find the union of two polygons in GeoPandas and output a single geometry that encompasses points from both polygons as its vertices.  The <code>geopandas.overlay</code> function gives me polygons for each individual union but I would like a single polygon.  </p>

<p>For context, I'm using this to combine two administrative areas together into a single area (i.e. include a town district within a country).  </p>

<p>The following example is from the geopandas website and illustrates what I'd like:</p>

<pre><code>from matplotlib import pyplot as plt
import geopandas as gpd
from shapely.geometry import Polygon

polys1 = gpd.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)]),
                         Polygon([(2,2), (4,2), (4,4), (2,4)])])

polys2 = gpd.GeoSeries([Polygon([(1,1), (3,1), (3,3), (1,3)]),
                         Polygon([(3,3), (5,3), (5,5), (3,5)])])

df1 = gpd.GeoDataFrame({'geometry': polys1, 'df1':[1,2]})
df2 = gpd.GeoDataFrame({'geometry': polys2, 'df2':[1,2]})

res_union = gpd.overlay(df1, df2, how='union')
res_union.plot()
</code></pre>

<p><a href="https://i.stack.imgur.com/lqmnQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lqmnQ.png" alt="res_union.png"></a></p>

<p>None of the output geometries are what I was expected, which is the following:</p>

<pre><code>poly_union = gpd.GeoSeries([Polygon([(0,0), (0,2), (1,2), (1,3), \
    (2,3), (2,4), (3, 4), (3, 5), (5, 5), (5, 3), (4, 3), (4, 2), \
    (3,2), (3,1), (2, 1), (2, 0), (0, 0)])])

poly_union.plot(color = 'red')
plt.show()
</code></pre>

<p><a href="https://i.stack.imgur.com/zDTGD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zDTGD.png" alt="union.png"></a></p>

<p>Firstly, how do I output the above polygon (<code>poly_union</code>) from the input polygons (<code>df1</code>, <code>df2</code>) using GeoPandas or shapely?  </p>

<p>Secondly, what is the correct nomenclature associated with the geometry (<code>poly_union</code>) that I'm trying to find?  I would call it a 'union' but every example I find that refers to 'unions' does not output this geometry.  </p>

<p>Note: <a href="https://stackoverflow.com/questions/34325030/merging-two-geojson-polygons-in-python">This</a> example does not seem to output a single polygon either:</p>

<pre><code>poly1 = df1['geometry']; poly2 = df2['geometry']
mergedpoly = poly1.union(poly2)
mergedpoly.plot()
</code></pre>

<p><a href="https://i.stack.imgur.com/llKmE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/llKmE.png" alt="merged_poly.png"></a></p>