Make a union of polygons in GeoPandas, or Shapely (into a single geometry)

Note: cascaded_union mentioned in the answer below is superceded by unary_union if GEOS 3.2+ is used - this allows unions on different geometry types, not only polygons. To check your version,

>>> shapely.geos.geos_version
(3, 5, 1)

From the question/answer here, it seems this is called a cascaded_union within shapely:

from shapely.ops import cascaded_union
polygons = [poly1[0], poly1[1], poly2[0], poly2[1]]
boundary = gpd.GeoSeries(cascaded_union(polygons))
boundary.plot(color = 'red')
plt.show()

union


If you prefer Geopandas over Shapely you might consider dissolve and use a column with a constant value for all entries: http://geopandas.org/aggregation_with_dissolve.html


@Rutger Hofste's answer worked best for me as well. In case your polygons are lacking of a column with a constant value, just simply create one by

gdf['new_column'] = 0 gdf_new = gdf.dissolve(by='new_column')