I have a large polygon shapefile and a small polygon shapefile. Both shapefiles are in the same coordinate system. What I do next is, clip small polygons within large polygon boundaries using GeoPandas's Clip.
And here comes the question, before clipping, small polygon geometry contains only Polygon features and not MultiPolygon, but after using
geopandas clip(), some small polygon geometry transforms to MultiPolygons. Is there some specific reason why it happens? I should use the polygons in further analysis where I assume, because of this which will arise some error or problem.
Note: none of the small, neither large polygons overlay.
I did try to transform the MultiPolygons to Polygons with
gpd.explode(), which gave me
geopandas.geoseries.GeoSeries and the result below, however it can be noted that some polygon
"ID" are missing, I also cannot assign an
"ID" to each feature with
df['ID'] = df.index(). Then arises an error:
TypeError: 'MultiIndex' object is not callable.
Is there some explanation why I get MultiPolygons instead of Polygons in the
import geopandas as gpd small = gpd.read_file(r'R:\...\small.shp') large = gpd.read_file(r'R:\...\large.shp') smallClip = gpd.clip(small, large) smallClip_explode = smallClip['geometry'].explode() print(type(smallClip_explode)) Out: geopandas.geoseries.GeoSeries gdf = gpd.GeoDataFrame(geometry=gpd.GeoSeries(smallClip_explode))