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

rioxarray can't clip nc files by the samll bound files? #716

Closed
CGL5230 opened this issue Dec 4, 2023 · 3 comments
Closed

rioxarray can't clip nc files by the samll bound files? #716

CGL5230 opened this issue Dec 4, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@CGL5230
Copy link

CGL5230 commented Dec 4, 2023

for idx, row in gdf.iterrows():
    name = row['NAME']  
    geometry = row['geometry']  
    print(row['NAME'])
    ERA5_AP_ds = ERA5_AP.rio.clip([geometry],all_touched=True)
    AWI_CM_ssp126_AP_ds = AWI_CM_ssp126_AP.rio.clip([geometry],all_touched=True)

Problem description

Hi,all! I try to clip the netcdf files with the shape files. It is worth noting that this shp file contains a number of sub-regions within it. The code above is cropping all the sub-regions. But again, this results in the boundaries of the crop becoming very small. As a result, the error was report:“NoDataInBounds: No data found in bounds.”
I think the small boundary will the core of problem and related to this post. It is Archipiélago de Revillagigedo(location) and the resolution of cmip6 is 0.9 degree.

image

Expected Output

I set the all_touched=True that means I'll get at least one like grid point value.

Environment Information

  • python -c "import rioxarray; rioxarray.show_versions()"
  • rioxarray version:0.15.0
  • rasterio version:1.3.9
  • Python version:3.11
  • Operation System Information:Linux

Installation method

pip

@CGL5230 CGL5230 added the bug Something isn't working label Dec 4, 2023
@CGL5230
Copy link
Author

CGL5230 commented Dec 5, 2023

As you can see the geometry touched the grid. But still report "No data in bounds"
image

@CGL5230
Copy link
Author

CGL5230 commented Dec 11, 2023

I meet the same error again. I think the point is cropped_ds.coords[self.x_dim].size < 1 or cropped_ds.coords[self.y_dim].size < 1. You can see the boundary for another shape file. Is there anyway to return the touched cells for rio.clip method?
By the way, can I use the clip.box to clip? How can I pass my shape file boundary to this?
image

I meet a werid problem... The length of boundary is more than cropped_ds.coords[self.x_dim].size < 1 or cropped_ds.coords[self.y_dim].size < 1. But still report "No data in Bounds" error.
image

@CGL5230
Copy link
Author

CGL5230 commented Dec 15, 2023

I think the reason is the longitude of the dataset. It's range is 0-360 degree. So I minus 180 with the lon parameter. It work!

@CGL5230 CGL5230 closed this as completed Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant