geocube
geocube copied to clipboard
[Feature] Is it possible to add the funcitonability of polygonizing
First, thank you very much for this package, which helps solve the pain point of converting Geopandas vector data to tif through xarray. May I ask if the package can also facilitate converting an Xarray dataset to Geopandas vectors (polygonizing). That would be much convenient than using gdal functions. Thank you very much.
@Meresmata Did you ever end up building any
raster->vector
functionality? I found this issue while searching for similar functionality, and ended up creating my own implementation to build a geodataframe usingrasterio.features.shapes
on an xarray dataset. It's highly application specific (loops through only one variable based on the time dimension) and the code still needs some cleanup, but I wanted to share in case it's helpful. Where the variable data fit into memory it was as simple as adding the transform input toshapes()
. The trickier part was when the variable data was a dask array that didn't all fit into memory, so a geotransform needed to be constructed per-chunk and then fed intoshapes()
within adask.delayed
function call.
Originally posted by @JessicaS11 in https://github.com/corteva/rioxarray/issues/159#issuecomment-801210867
This is something that I think would make sense to add to geocube if someone wanted to take a stab at it.
Raster->Vector? I normally rasterstats for it, but this is probably something completely different, from what you intended!
I never had problems that a raster fits into the memory! The think is a) perhaps you have invoke the garbage collector? That's what helps me normally, when processing several rasters after another or with multiprocessing. I never had to deal with a single raster, that was larger than my RAM!
Related: https://github.com/xarray-contrib/xvec