I have a multipolygon GeoPandas DataFrame. I want to create a KML file from each polygon of geodataframe.
gdf
sites geometry
0 site1 POLYGON ((-83.45951 35.03725, -83.45963 35.037...
1 site2 POLYGON ((-83.46075 35.03702, -83.46086 35.037...
2 site3 POLYGON ((-76.56159 38.89046, -76.56166 38.890...
3 site4 POLYGON ((-76.55872 38.89012, -76.55875 38.890...
4 site5 POLYGON ((-59.86998 -2.40509, -59.87006 -2.405...
I've done this so far:
fiona.supported_drivers['KML'] = 'rw' #fiona library wrapped by geopandas supports unofficialy a KML driver that you have to enable by hand.
for index, row in gdf.iterrows():
file_names = row["sites"]
output_name = f"{file_names}.kml"
# Create an output path
outpath = os.path.join(result_folder, output_name)
# Export the data
new_kml = gpd.GeoDataFrame(row, row.geometry)
new_kml.to_file(outpath, driver='KML')
But getting following error:
new_kml = gpd.GeoDataFrame(row, row.geometry)
TypeError: 'Polygon' object is not iterable