cf-xarray icon indicating copy to clipboard operation
cf-xarray copied to clipboard

Add grid_bounds_to_polygons

Open dcherian opened this issue 3 years ago • 2 comments

  • [x] Add to api.rst
  • [ ] Add test

This converts "bounds" in the 2-element form to an array of shapely polygons, one per grid cell. A step towards nicely packaging conservative regridding for the ecosystem. It could easily be generalized to the 4-element "vertex" form

Modified from https://notebooksharing.space/view/c6c1f3a7d0c260724115eaa2bf78f3738b275f7f633c1558639e7bbd75b31456#displayOptions=

cc @martinfleis @benbovy @aulemahal for awareness. I'm not sure if this is at all useful for xvec but on the off-chance that it is..

dcherian avatar Oct 26 '23 04:10 dcherian

Codecov Report

Attention: 26 lines in your changes are missing coverage. Please review.

Comparison is base (02b1d74) 83.82% compared to head (d33610e) 83.06%.

Files Patch % Lines
cf_xarray/geometry.py 7.14% 26 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #478      +/-   ##
==========================================
- Coverage   83.82%   83.06%   -0.77%     
==========================================
  Files          14       14              
  Lines        2770     2799      +29     
  Branches      208      208              
==========================================
+ Hits         2322     2325       +3     
- Misses        397      423      +26     
  Partials       51       51              
Flag Coverage Δ
mypy 43.75% <10.34%> (-0.36%) :arrow_down:
unittests 92.89% <7.14%> (-1.35%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 26 '23 04:10 codecov[bot]

In Xvec we could flatten the array and use it as an index instead of latitude and longitude coordinates if there's a use case for that.

martinfleis avatar Oct 26 '23 08:10 martinfleis