I have a Dataframe as below. If a FID contains more than one polygons I need to create Multipolygon for FID. In my Dataframe I have FID 978 which contains two polygons so it should be converted to Multipolygon otherwise polygon.
|FID|Geometry|
|975|POLYGON ((-94.2019149289999 32.171910245, -94.201889847 32.171799917, -94.2019145369999 32.1719110220001, -94.2019344619999 32.171974117, -94.2019149289999 32.171910245))
|976|POLYGON ((-94.204485668 32.175813341, -94.2045721649999 32.1758854190001, -94.2044856639999 32.1758124690001, -94.204358881 32.1757171630001, -94.204485668 32.175813341))
|978|POLYGON ((-94.30755277 32.402906479, -94.321881945 32.4028226820001, -94.321896361 32.4035500580001, -94.3074214489999 32.4037557020001, -94.3075504129999 32.4029064600001, -94.30755277 32.402906479))
|978|POLYGON ((-94.30755277 32.402906479, -94.307552779 32.4005399370001, -94.307558688 32.4005401040001, -94.30755277 32.402906479))
I am using the following function to convert Multipolygons
def ploygon_to_multipolygon(wkt):
list_polygons = [wkt.loads(poly) for poly in wkt]
return shapely.geometry.MultiPolygon(list_polygons)
looks like polygons are not converting to Multipolygons.