csiro-coasts / emsarray

xarray extension that supports EMS model formats
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Faster polygon construction using Shapely 2.0.0 #47

Closed mx-moth closed 1 year ago

mx-moth commented 1 year ago

Shapely 2 exposes a shapely.polygons function which can create large numbers of polygons directly from numpy arrays. This gives a dramatic performance improvement, varying by dataset type. For UGRID I have seen the time taken to construct the polygons halve, for large CF grids the time has dropped from ~6 seconds to ~0.1 second.

This makes #40 irrelevant. This was found when investigating caching strategies. The slow down was always in constructing the polygons not in calculating vertices, and polygons still have to be constructed when loading them from the cache.