Closed dkczk closed 1 year ago
The coordinates of the grid cell represent the centroid of the grid cell. To get the boundary of the raster, you have to take into account the resolution of the grid cell and add/subtract from the bounding centroid coordinates.
Ahhh obvious. Thank you!
Problem description
I want to create a dummy raster with an extent of 3x3 degrees and a specific resolution which I can later use for the
reproject_match()
function. The chosen resolution of 0.00008 degrees results in a raster with 37500 rows and cols. After writing the CRS using rio.write_crs() the extent is shifted by half a cell and obviously I don't want that.dummy.rio.bounds()
gives(11.99996, 50.99996, 14.99996, 53.99996)
. I've already checked, if the problem is the DataArray withdummy_x = dummy.coords["x"].values
. But there the coordinates are as expected and wanted.Expected Output
dummy.rio.bounds()
should return(12.0, 51.0, 15.0, 54.0)
.Environment Information
python (3.10.8) rioxarray (0.13.3) xarray (2022.12.0)
Installation method
conda
Conda environment information (if you installed with conda):
Conda Version: 22.11.1 libgdal 3.6.1 hf2b5f72_1 conda-forge rasterio 1.3.4 py310hfc14bbd_0 conda-forge rioxarray 0.13.3 pyhd8ed1ab_0 conda-forge xarray 2022.12.0 pyhd8ed1ab_0 conda-forge