I get the following error when trying to clip a GeoTiff to a shapefile: "No data found in bounds."
Steps to reproduce:
import rioxarray as riox
rain = riox.open_rasterio(
"https://s3-ap-southeast-2.amazonaws.com/silo-open-data/daily/daily_rain/2001/20010101.daily_rain.tif"
)
rain
<xarray.DataArray (band: 1, y: 681, x: 841)>
[572721 values with dtype=float32]
Coordinates:
* band (band) int64 1
* y (y) float64 -10.0 -10.05 -10.1 -10.15 ... -43.9 -43.95 -44.0
* x (x) float64 112.0 112.0 112.1 112.1 ... 153.8 153.9 153.9 154.0
spatial_ref int64 0
Attributes:
_FillValue: -32767.0
scale_factor: 1.0
add_offset: 0.0
long_name: Daily rainfall
units: mm
grid_mapping: spatial_ref
rain.rio.crs
CRS.from_epsg(4326)
geom = [{'type': 'Polygon',
'coordinates': [[[149.8422409924085, -30.2606878927815],
[149.8432272914562, -30.260198054517836],
[149.84674418853774, -30.258451413106968],
[149.84699580073607, -30.25832645173489],
[149.86067125124407, -30.25522463855303],
[149.86064473604847, -30.255375372072535],
[149.86158897369342, -30.255160332512734],
[149.87138973091908, -30.25358008629615],
[149.8749496072403, -30.25278056138403],
[149.87751267502404, -30.25210408302803],
[149.88000469636745, -30.250997066023213],
[149.88698199640032, -30.249275066568426],
[149.88897543361065, -30.248906051660306],
[149.89260653623649, -30.25025904775652],
[149.89267758267692, -30.252473085924183],
[149.89832667009966, -30.2588351623366],
[149.90122866864897, -30.262103431198284],
]]}]
rain.rio.clip(geom)
NoDataInBounds Traceback (most recent call last)
<ipython-input-64-9fe38157f4ee> in <module>
----> 1 rain.rio.clip(geom)
/opt/conda/lib/python3.8/site-packages/rioxarray/raster_array.py in clip(self, geometries, crs, all_touched, drop, invert, from_disk)
729 or cropped_ds.coords[self.y_dim].size < 1
730 ):
--> 731 raise NoDataInBounds(
732 f"No data found in bounds.{_get_data_var_message(self._obj)}"
733 )
NoDataInBounds: No data found in bounds.
NOTE: the geometry x and y max and min are within the max and min x, y of the GeoTiff!