It's a bit slow, but sp::over seems to be slow for SpatialPoints, SpatialPolygons (why?).
Here it takes 15 seconds to extract one polygon for 31 time steps, but all the time is taken by the point in polygon look up so the subsequent extraction from files shouldn't be too bad.
This needs us to be able to put sf objects in "non-geographic" spaces, to nominate any pair of dimensions in NetCDF so we can extract - and the polygon overlay is simply a grouped filter applied to the flattened slab.
expt-group-by contains a hyper_group_by which applies a "nominal-2D" grid coordinate point in polygon approach to the "polygon overlay" task.
http://rpubs.com/cyclemumner/284383
It's a bit slow, but sp::over seems to be slow for SpatialPoints, SpatialPolygons (why?).
Here it takes 15 seconds to extract one polygon for 31 time steps, but all the time is taken by the point in polygon look up so the subsequent extraction from files shouldn't be too bad.
This needs us to be able to put sf objects in "non-geographic" spaces, to nominate any pair of dimensions in NetCDF so we can extract - and the polygon overlay is simply a grouped filter applied to the flattened slab.