Skip to content

Commit

Permalink
EP-3827 include band metadata in asset
Browse files Browse the repository at this point in the history
  • Loading branch information
jdries committed Apr 8, 2021
1 parent d640ec5 commit 5c1e927
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/test_save_result_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from openeo_driver.save_result import AggregatePolygonResult
from shapely.geometry import GeometryCollection, Polygon

from openeo.metadata import CollectionMetadata


def test_aggregate_polygon_result_basic(tmp_path):
timeseries = {
Expand All @@ -16,10 +18,22 @@ def test_aggregate_polygon_result_basic(tmp_path):
Polygon([(6, 1), (1, 7), (9, 9)])
])

result = AggregatePolygonResult(timeseries, regions=regions)
metadata = CollectionMetadata({
"cube:dimensions": {
"x": {"type": "spatial"},
"b": {"type": "bands", "values": ["red", "green","blue"]}
}
})

result = AggregatePolygonResult(timeseries, regions=regions, metadata=metadata)
result.set_format("netcdf")

filename = result.to_netcdf(tmp_path / 'timeseries_xarray.nc')
assets = result.write_assets(tmp_path)
theAsset = assets.popitem()[1]
filename = theAsset['href']

assert 'application/x-netcdf' == theAsset['type']
assert ["red", "green", "blue"] == [b['name'] for b in theAsset['bands']]

timeseries_ds = xr.open_dataset(filename)
print(timeseries_ds)
Expand Down

0 comments on commit 5c1e927

Please sign in to comment.