Skip to content

Commit

Permalink
[#8] saving the newly created vrt file for raster as content file
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdash committed Jun 20, 2024
1 parent ee5b2a9 commit 811c273
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion hsextract/raster/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from textwrap import indent
import shutil
from osgeo.gdalconst import GA_ReadOnly
from osgeo import osr, gdal
from collections import OrderedDict
Expand All @@ -24,6 +24,16 @@ def extract_from_tif_file(tif_file):
tif_files = [os.path.join(full_path, f) for f in tif_files] + [tif_file]
# file validation and metadaadatta extraction
file_type_metadata = extract_metadata_from_vrt(filename)

# save the new vrt file to the location of the tif file
if ext != ".vrt":
vrt_file_path = Path(tif_file).parent / f"{Path(tif_file).stem}.vrt"
shutil.move(filename, vrt_file_path)
log_message = f">> A new vrt file was saved to {vrt_file_path}"
print(log_message)
logging.info(log_message)
tif_files += [str(vrt_file_path)]

file_type_metadata["content_files"] = tif_files

return file_type_metadata
Expand Down

0 comments on commit 811c273

Please sign in to comment.