Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'intersects' option to subset bbox and shape #253

Open
RondeauG opened this issue Oct 6, 2022 · 2 comments
Open

Add a 'intersects' option to subset bbox and shape #253

RondeauG opened this issue Oct 6, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@RondeauG
Copy link
Collaborator

RondeauG commented Oct 6, 2022

  • clisops version: 0.9.3

Description

Currently, clisops will subset a dataset based on the lat/lon coordinate of the grid pixels, meaning that the center of the pixel needs to be inside the region to be kept. An option to instead keep all the pixels that touch the region would be very useful.

I realise that the buffer argument of subset_shape already serves that purpose, but it can be difficult to use effectively since the optimal value depends on model resolution. At minimum, however, a similar option should be included for subset_bbox too.

@aulemahal
Copy link
Collaborator

That would necessitate the cell boundaries I believe. Similarly with xESMF, this is trivial to obtain for rectilinear grids, but not for curvilinear (rotated pole) ones. Would you be ok if this had the same conditions as in xESMF? i.e. : When touching = True, if lat and lon are 2D arrays and ds.cf.get_bounds fails, then the function fails.

@Zeitsperre Zeitsperre added the enhancement New feature or request label Oct 6, 2022
@RondeauG
Copy link
Collaborator Author

RondeauG commented Oct 6, 2022

I think so, but in that case we'd definitely need both buffer and touching for subset_shape and subset_bbox. This way, buffer could still be used for curvilinear grids.

Also, reading a little more on which features shapely has, I think that intersects or overlaps would be better terms than touches/touching.

From https://shapely.readthedocs.io/en/stable/manual.html#object.intersects:

  • object.intersects(other)
    Returns True if the boundary or interior of the object intersect in any way with those of the other.
  • object.overlaps(other)
    Returns True if the geometries have more than one but not all points in common, have the same dimension, and the intersection of the interiors of the geometries has the same dimension as the geometries themselves.
  • object.touches(other)
    Returns True if the objects have at least one point in common and their interiors do not intersect with any part of the other.

@RondeauG RondeauG changed the title Add a 'touching' option to subset bbox and shape Add a 'intersects' option to subset bbox and shape Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants