diff --git a/openeo_driver/datacube.py b/openeo_driver/datacube.py index bdec1d90..1351b7be 100644 --- a/openeo_driver/datacube.py +++ b/openeo_driver/datacube.py @@ -224,7 +224,9 @@ class DriverVectorCube: DIM_PROPERTIES = "properties" COLUMN_SELECTION_ALL = "all" COLUMN_SELECTION_NUMERICAL = "numerical" - VECTOR_CUBE_DUMMY = "vector_cube_dummy" + + # Xarray cube attribute to indicate that it is a dummy cube + CUBE_ATTR_VECTOR_CUBE_DUMMY = "vector_cube_dummy" def __init__( self, @@ -325,7 +327,7 @@ def from_geodataframe( data=numpy.full(shape=[data.shape[0]], fill_value=numpy.nan), dims=[cls.DIM_GEOMETRIES], coords={cls.DIM_GEOMETRIES: data.geometry.index.to_list()}, - attrs={cls.VECTOR_CUBE_DUMMY: True}, + attrs={cls.CUBE_ATTR_VECTOR_CUBE_DUMMY: True}, ) return cls(geometries=data, cube=cube) @@ -419,7 +421,7 @@ def _as_geopandas_df( """Join geometries and cube as a geopandas dataframe""" # TODO: avoid copy? df = self._geometries.copy(deep=True) - if self._cube is not None and not self._cube.attrs.get(self.VECTOR_CUBE_DUMMY): + if self._cube is not None and not self._cube.attrs.get(self.CUBE_ATTR_VECTOR_CUBE_DUMMY): assert self._cube.dims[0] == self.DIM_GEOMETRIES # TODO: better way to combine cube with geometries # Flatten multiple (non-geometry) dimensions from cube to new properties in geopandas dataframe @@ -514,7 +516,7 @@ def to_legacy_save_result(self) -> Union["AggregatePolygonResult", "JSONResult"] # TODO: eliminate these legacy, non-standard formats? from openeo_driver.save_result import AggregatePolygonResult, JSONResult - if self._cube is None: + if self._cube is None or self._cube.attrs.get(self.CUBE_ATTR_VECTOR_CUBE_DUMMY): # No cube: no real data to return (in legacy style), so let's just return a `null` per geometry. return JSONResult(data=[None] * self.geometry_count())