I'm trying to create a dummy raster which I can later use as target for rioxarrays reproject_match() function. My area of interest (AOI) is exactly 3x3 degrees and my desired resolution is 0.00008. So the resolution fits exactly into the AOI with 37500 rows and columns. I did:
import xarray as xr
import rioxarray as rio
res = 0.00008
dec = abs(decimal.Decimal(str(res)).as_tuple().exponent)
lon = list(np.arange(12, 15, res))
lon = [round(x, dec) for x in lon]
lat = list(np.arange(51, 54, res))
lat = [round(x, dec) for x in lat]
dummy = xr.DataArray(
data=1,
dims=["x", "y"],
coords={"x": lon, "y": lat},
name="dummy"
)
dummy.rio.write_crs("epsg:4326", inplace=True)
When I check the boundaries with:
dummy.rio.bounds()
I get (11.99996, 50.99996, 14.99996, 53.99996)
when the extent should be (12.0, 51.0, 15.0, 54.0). Why is that and how to solve this issue?