Skip to content

Commit

Permalink
Avoid error when getting band_names. Open-EO/openeo-geopyspark-driver…
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileSonneveld committed Jan 8, 2025
1 parent ad73911 commit fd1933d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions openeo_driver/save_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,14 @@ def to_geoparquet(self, destination: Optional[str] = None) -> str:
n_band_values = len(band_values)
flattened.append((timestamp, feature_index, *band_values))

band_names = [f"band_{i}" for i in range(n_band_values)]
if self._metadata is not None and self._metadata.has_band_dimension() and len(band_names) == len(self._metadata.bands):
if (
self._metadata is not None
and self._metadata.has_band_dimension()
and (n_band_values is None or n_band_values == len(self._metadata.bands))
):
band_names = self._metadata.band_names
else:
band_names = [f"band_{i}" for i in range(n_band_values)]

stats = pd.DataFrame.from_records(flattened,
columns=['date', 'feature_index'] + band_names)
Expand Down

0 comments on commit fd1933d

Please sign in to comment.