nismod / snail

spatial networks impact assessment library 🐌
https://nismod.github.io/snail/
MIT License
9 stars 1 forks source link

Performance improvements #30

Open tomalrussell opened 2 years ago

tomalrussell commented 2 years ago

Opening an issue to keep a note of performance improvement ideas. Feel free to edit and add to this list:

Rough benchmarking for ~570,000 edges, split to ~600,000 splits on ~1km² grid. (OpenStreetMap Bangladesh highways, only trunk to tertiary).

operation implementation time
Split to long GeoDataFrame snail.multi_intersections.split_linestrings 1min 13s ± 2.6 s
Look up cell index for splits splits.geometry.apply(lambda g: list(get_cell_indices(g, r.width, r.height, list(r.transform)))) 59.8 s ± 166 ms
Get raster values using cell index splits.cell_index.apply(lambda i: data[i[1], i[0]]) 364 ms ± 15.1 ms