Skip to content

Commit

Permalink
encapsulate tiffset
Browse files Browse the repository at this point in the history
  • Loading branch information
bossie committed Sep 26, 2024
1 parent c48504f commit 272d1ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 2 additions & 3 deletions openeogeotrellis/geopysparkdatacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {}

Expand Down
8 changes: 8 additions & 0 deletions openeogeotrellis/integrations/tiffset.py
Original file line number Diff line number Diff line change
@@ -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)])

0 comments on commit 272d1ff

Please sign in to comment.