Open
Description
As I mentioned here, when I add a raster inside a geocube are produced a lot of nodata.
After a test @snowman2 has indicates that this is a possible bug of xarray libraries.
I was able to reproduce the issue you demonstrated. I think it has to do with decimal precision of the coordinates when adding the DataArray to the Dataset. That being said, I checked that the
x
coordinate andy
coordinates were the exact same forraster_in
andout_grid
. This is likely an issue withxarray
and notgeocube
.For a workaround, this got it working without the gaps for me:
import geopandas import rioxarray from geocube.api.core import make_geocube vector_in = geopandas.read_file("vector_data.shp") raster_in = rioxarray.open_rasterio("raster_data.tif", masked=True).sel(band=1).drop("band") out_grid = make_geocube( vector_data=vector_in, measurements=["id"], like=raster_in, ) out_grid["process_value"] = (raster_in.dims, raster_in.values, raster_in.attrs, raster_in.encoding)
Metadata
Metadata
Assignees
Labels
No labels