Skip to content

Cropping dataset with rotated poles #8082

Answered by kmuehlbauer
ClimateYukon asked this question in Q&A
Discussion options

You must be logged in to vote

Re-gridding to 1D lat/lon always involves interpolation and that is sometimes not really wanted. There is #2281 discussing potential approaches.

You might also use the provided 2D lat/lon coordinates for cropping/masking. As always this depends on your actual use-case. The below example just crops with a simple bounding box.

ds_clip = ds.where(
    (
        ((ds.lat > bbox["bottom"]) & (ds.lat < bbox["top"]))
        & ((ds.lon > bbox["left"]) & (ds.lon < bbox["right"]))
    ),
    drop=True,
)

Another approach would be to project your shapefile coordinates into the rotated pole domain and do cropping and all further computation in that domain. This at least excludes any errors which mig…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ClimateYukon
Comment options

Answer selected by ClimateYukon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants