[GIS] Geopandas simplify results in gaps between polygons

geopandasshapelysimplify

The goal is to simplify the geometries of a shapefile containing multipolygons. However, when I use Shapely's simplify in geopandas, the result contains gaps between the polygons. I was hoping that preserve_topology would avoid this? How can I avoid or fix the issue?

gdf_simplified = gdf.copy()
gdf_simplified["geometry"] = gdf.geometry.simplify(tolerance=TOLERANCE,preserve_topology=True)

my geoDataFrame is in in {'init': 'epsg:4326'}and I use a tolerance of 360/43200 which corresponds to 30" degrees (appr. 1 km at the equator).

enter image description here

The old polygons are displayed using the black line. The new resulting polygons are depicted using colors.

For now, I was able to revert to MapShaper and get simplified shapes without the gaps. However, I would prefer a python based approach.

Best Answer

As mentioned, you need a topology aware simplification algorithm. For this I use the topojson package:

gdf = <geopandas dataframe>

import topojson as tp

topo = tp.Topology(gdf.to_crs({'init':'epsg:3857'}), prequantize=False)
simple = topo.toposimplify(1).to_gdf()

# optional
simple.plot()