Losing data when add a raster to a geocube
See original GitHub issueI don’t know if it is a bug or my misunderstanding, but I’m following this example without fortune.
vector_in = geopandas.read_file(input_vector)
raster_in = rioxarray.open_rasterio(input_raster)
out_grid = make_geocube(
vector_data=vector_in,
measurements=["id"],
like=raster_in,
)
When I use out_grid["process_value"] = raster_in
and later out_grid.to_netcdf('mydata.nc')
I see that the output has a lot of nodata. But neither vector_in
or raster_in
have this amount of nodata.
Here there is a QGIS project with my data.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Example - Filling in missing data & dealing with timestamps
Example - Filling in missing data & dealing with timestamps · Load in geopackage data and add CRS ·...
Read more >No data returned when rasterizing specific measurements #50
I'd like plot the data but the conventional .plot() fails i presume because all that is in my output raster is coordinates -...
Read more >How to use geocube with option -at (all_touched=TRUE)
First, I want to rasterize roads separately to make them look better by using the option "all_touched"=True. And then I want to merge...
Read more >Add Rasters To Mosaic Dataset (Data Management)—ArcMap
ArcGIS geoprocessing tool that adds raster datasets from a file, a folder, a raster catalog, or an image service to a mosaic dataset....
Read more >geocube Changelog - PyUp.io
Add "all_touched" keyword argument to geocube.rasterize.rasterize_image ... Added filter_nan kwarg to filter out missing data when rasterizing (issue 9)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
Will need to dig into it later to see what is going on. Thanks for the images, that is helpful.