최근에 셰이프 파일 작업을 시작했습니다. 각 개체가 다각형 인 shapefile이 있습니다. 각 다각형의 기하 구조가 중심으로 대체되는 새로운 shapefile을 생성하려고합니다. 내 코드가있다.geopandas를 사용하여 모양 파일을 만들 때 ValueError 발생
import geopandas as gp
from shapely.wkt import loads as load_wkt
fname = '../data_raw/bg501c_starazagora.shp'
outfile = 'try.shp'
shp = gp.GeoDataFrame.from_file(fname)
centroids = list()
index = list()
df = gp.GeoDataFrame()
for i,r in shp.iterrows():
index.append(i)
centroid = load_wkt(str(r['geometry'])).centroid.wkt
centroids.append(centroid)
df['geometry'] = centroids
df['INDEX'] = index
gp.GeoDataFrame.to_file(df,outfile)
내가 raise ValueError("Geometry column cannot contain mutiple " ValueError: Geometry column cannot contain mutiple geometry types when writing to file.
와 끝까지 스크립트를 실행하면 내가 잘못이 무엇인지 이해할 수 없습니다. 어떤 도움이 필요합니까?