import os
import xarray as xr
import xvec
import shapely
"ZARR_V3_EXPERIMENTAL_API"] = "1" os.environ[
Generate vector data cube
Generate a vector data cube representation of the final data product, using CF encoding of geometries.
= xr.open_zarr("/eurofab_predictions_datacube.zarr", zarr_format=3).load() ds
/Users/martin/dev/xvec/.pixi/envs/default/lib/python3.13/site-packages/zarr/codecs/vlen_utf8.py:44: UserWarning: The codec `vlen-utf8` is currently not part in the Zarr format 3 specification. It may not be supported by other zarr implementations and may change in the future.
return cls(**configuration_parsed)
'geometry'] = xr.apply_ufunc(shapely.from_wkt, ds['geometry']) ds[
= ds.swap_dims(obs='geometry').drop_vars('obs').xvec.set_geom_indexes("geometry", crs=27700) vdc
= vdc.drop_vars(['lon', 'lat']).xvec.encode_cf() encoded
"eurofab_predictions_vector_datacube.zarr", mode="w") encoded.to_zarr(
/Users/martin/dev/xvec/.pixi/envs/default/lib/python3.13/site-packages/zarr/api/asynchronous.py:205: UserWarning: Consolidated metadata is currently not part in the Zarr format 3 specification. It may not be supported by other zarr implementations and may change in the future.
warnings.warn(
<xarray.backends.zarr.ZarrStore at 0x3ccce3be0>