@@ -224,7 +224,9 @@ class DriverVectorCube:
224
224
DIM_PROPERTIES = "properties"
225
225
COLUMN_SELECTION_ALL = "all"
226
226
COLUMN_SELECTION_NUMERICAL = "numerical"
227
- VECTOR_CUBE_DUMMY = "vector_cube_dummy"
227
+
228
+ # Xarray cube attribute to indicate that it is a dummy cube
229
+ CUBE_ATTR_VECTOR_CUBE_DUMMY = "vector_cube_dummy"
228
230
229
231
def __init__ (
230
232
self ,
@@ -325,7 +327,7 @@ def from_geodataframe(
325
327
data = numpy .full (shape = [data .shape [0 ]], fill_value = numpy .nan ),
326
328
dims = [cls .DIM_GEOMETRIES ],
327
329
coords = {cls .DIM_GEOMETRIES : data .geometry .index .to_list ()},
328
- attrs = {cls .VECTOR_CUBE_DUMMY : True },
330
+ attrs = {cls .CUBE_ATTR_VECTOR_CUBE_DUMMY : True },
329
331
)
330
332
return cls (geometries = data , cube = cube )
331
333
@@ -419,7 +421,7 @@ def _as_geopandas_df(
419
421
"""Join geometries and cube as a geopandas dataframe"""
420
422
# TODO: avoid copy?
421
423
df = self ._geometries .copy (deep = True )
422
- if self ._cube is not None and not self ._cube .attrs .get (self .VECTOR_CUBE_DUMMY ):
424
+ if self ._cube is not None and not self ._cube .attrs .get (self .CUBE_ATTR_VECTOR_CUBE_DUMMY ):
423
425
assert self ._cube .dims [0 ] == self .DIM_GEOMETRIES
424
426
# TODO: better way to combine cube with geometries
425
427
# 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"]
514
516
# TODO: eliminate these legacy, non-standard formats?
515
517
from openeo_driver .save_result import AggregatePolygonResult , JSONResult
516
518
517
- if self ._cube is None :
519
+ if self ._cube is None or self . _cube . attrs . get ( self . CUBE_ATTR_VECTOR_CUBE_DUMMY ) :
518
520
# No cube: no real data to return (in legacy style), so let's just return a `null` per geometry.
519
521
return JSONResult (data = [None ] * self .geometry_count ())
520
522
0 commit comments