You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it is not really regridding, aggregation to a shapefile (polygons) should also be possible as an extension to the current capabilities. This can aid, e.g., hydrologists in aggregation of precipitation to a basin.
PyShp can read shapefiles and is implemented in pure python. Shapely has binary wheels on PyPI so it does not require compilation or conda.
In a quick test I have managed to get a 2D array with overlap fractions between a polygon from a shapefile and a grid.
Load in shapefile, grab first polygon
Turn grid coordinates into polygons using shapely.box
Compute overlap between every grid box and the shapefile polygon
Massage back into 2D array
This 2D array can be converted into weights to transform the gridded data into mean values. The 2D array can be (very) sparse.
Additional optimization can occur by making off part of the grid that is out of bounds of the shapefile polygon. This will speed up computation significantly.
While it is not really regridding, aggregation to a shapefile (polygons) should also be possible as an extension to the current capabilities. This can aid, e.g., hydrologists in aggregation of precipitation to a basin.
PyShp can read shapefiles and is implemented in pure python.
Shapely has binary wheels on PyPI so it does not require compilation or conda.
In a quick test I have managed to get a 2D array with overlap fractions between a polygon from a shapefile and a grid.
shapely.box
This 2D array can be converted into weights to transform the gridded data into mean values. The 2D array can be (very) sparse.
Additional optimization can occur by making off part of the grid that is out of bounds of the shapefile polygon. This will speed up computation significantly.
Quick demo here: https://gist.github.com/BSchilperoort/db955c4183b3721493875688d7417026
The text was updated successfully, but these errors were encountered: