Parallelize a function with multiple inputs/outputs geodataframe-variables

  geopandas, parallel-processing, pool, python, shapely

Using a previous answer (merci Booboo),
The code idea is:

from multiprocessing import Pool

def worker_1(x, y, z):
    ...
    t = zip(list_of_Polygon,list_of_Point,column_Point)
return t

def collected_result(t):
    x, y, z = t # unpack
    save_shp("polys.shp",x)
    save_shp("point.shp",y,z)

if __name__ == '__main__':
    pool = Pool()
    pool.map(worker_1, zip(MultiPolygon, lat, lon))
    pool.close()
    pool.join()  

But the geodataframe (Polygon,Point) is not iterable so I can’t use pool, any suggestions to parallelize?

How to compress the (geodataframe) outputs in worker_1 and then save them independently (or multiple layers in a shapefile), its better to use global parameters? … because zip only saves lists (right*)?

Source: Python Questions

LEAVE A COMMENT