Пример:
Код: Выделить всё
import geopandas as gpd
def myfunc(row):
#some processing using different attributes of row and row.geometry
#resulting in the creation of list of geometries with their own attributes
gdf_new = gpd.GeoDataFrame(new_geom_list, columns=['geometry'], geometry='geometry', crs=crs)
gdf_new['Attr1'] = attr1_list
gdf_new['Attr2'] = attr2_list
return gdf_new
gpd_out = gpd.GeoDataFrame()
crs = gpd_in.crs
for row in gpd_in.itertuples():
gpd_out = gpd.pd.concat([gpd_out, myfunc(row)], ignore_index = True)
Сначала я пытался использовать .apply, но кажется, что .apply не будет работать, поскольку myfunc возвращает новый кадр геоданных вместо изменения значения в строке.
Я попробовал Parallel из joblib следующим образом:
Код: Выделить всё
results = Parallel(n_jobs=-1)(delayed(myfunc)(row) for row in gpd_in.itertuples())
Код: Выделить всё
PicklingError: Could not pickle the task to send it to the workers.
Подробнее здесь: https://stackoverflow.com/questions/784 ... mes-in-pyt