diff --git a/openeogeotrellis/geopysparkdatacube.py b/openeogeotrellis/geopysparkdatacube.py index c98deca2..d307cbe0 100644 --- a/openeogeotrellis/geopysparkdatacube.py +++ b/openeogeotrellis/geopysparkdatacube.py @@ -43,6 +43,7 @@ from openeogeotrellis.config import get_backend_config from openeogeotrellis.configparams import ConfigParams from openeogeotrellis.geopysparkcubemetadata import GeopysparkCubeMetadata +from openeogeotrellis.integrations import tiffset from openeogeotrellis.integrations.gdal import GeoTiffMetadata from openeogeotrellis.ml.geopysparkmlmodel import GeopysparkMlModel from openeogeotrellis.processgraphvisiting import GeotrellisTileProcessGraphVisitor, SingleNodeUDFProcessGraphVisitor @@ -1957,9 +1958,7 @@ def color_to_int(color): geotiff_metadata.add_band_tag(tag_name, tag_value, band_index, role) for timestamped_path in timestamped_paths: - # TODO: encapsulate? use gdal instead? - args = ["tiffset", "-s", "42112", geotiff_metadata.to_xml(), timestamped_path._1()] - subprocess.check_call(args) + tiffset.embed_gdal_metadata(geotiff_metadata.to_xml(), timestamped_path._1()) assets = {} diff --git a/openeogeotrellis/integrations/tiffset.py b/openeogeotrellis/integrations/tiffset.py new file mode 100644 index 00000000..5ca70795 --- /dev/null +++ b/openeogeotrellis/integrations/tiffset.py @@ -0,0 +1,8 @@ +import subprocess +from pathlib import Path +from typing import Union + + +def embed_gdal_metadata(gdal_metadata_xml: str, geotiff_path: Union[Path, str]): + # TODO: use gdal instead to avoid warnings or are they harmless? + subprocess.check_call(["tiffset", "-s", "42112", gdal_metadata_xml, str(geotiff_path)])