Skip to content

Commit 2c89fb0

Browse files
committed
fixup! Issue #114/#211/#197 from_geodataframe: add dummy cube when no properties are specified
1 parent 9fb130a commit 2c89fb0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

openeo_driver/datacube.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class DriverVectorCube:
224224
DIM_PROPERTIES = "properties"
225225
COLUMN_SELECTION_ALL = "all"
226226
COLUMN_SELECTION_NUMERICAL = "numerical"
227+
VECTOR_CUBE_DUMMY = "vector_cube_dummy"
227228

228229
def __init__(
229230
self,
@@ -324,7 +325,7 @@ def from_geodataframe(
324325
data=numpy.full(shape=[data.shape[0]], fill_value=numpy.nan),
325326
dims=[cls.DIM_GEOMETRIES],
326327
coords={cls.DIM_GEOMETRIES: data.geometry.index.to_list()},
327-
attrs={"vector_cube_dummy": True},
328+
attrs={cls.VECTOR_CUBE_DUMMY: True},
328329
)
329330
return cls(geometries=data, cube=cube)
330331

@@ -418,7 +419,7 @@ def _as_geopandas_df(
418419
"""Join geometries and cube as a geopandas dataframe"""
419420
# TODO: avoid copy?
420421
df = self._geometries.copy(deep=True)
421-
if self._cube is not None:
422+
if self._cube is not None and not self._cube.attrs.get(self.VECTOR_CUBE_DUMMY):
422423
assert self._cube.dims[0] == self.DIM_GEOMETRIES
423424
# TODO: better way to combine cube with geometries
424425
# Flatten multiple (non-geometry) dimensions from cube to new properties in geopandas dataframe

tests/test_vectorcube.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_to_internal_json_defaults(self, gdf):
154154
"geometries": {"attrs": {}, "data": [0, 1], "dims": ("geometries",)},
155155
},
156156
"data": [IsNan(), IsNan()],
157-
"attrs": {},
157+
"attrs": {"vector_cube_dummy": True},
158158
},
159159
),
160160
(

0 commit comments

Comments
 (0)