Skip to content

Commit

Permalink
get first key/value from gdalinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvaingaudan committed Jul 17, 2024
1 parent 4445909 commit 1424b16
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions extensions/aproc/proc/ingest/drivers/impl/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ def to_item(self, url: str, assets: list[Asset]) -> Item:

gdalOptions = gdal.InfoOptions(format='json')
gdalInfo = gdal.Info(url, options=gdalOptions)

try:
creation_time = dateutil.parser.parse(gdalInfo.get("metadata", {}).get("", {}).get("creation_time", ""))
except dateutil.parser.ParserError:
metadata_keys = list(gdalInfo.get("metadata", {}))
if metadata_keys:
description = gdalInfo.get("metadata", {}).get(metadata_keys[0], {}).get("title", "TIFF file")
try:
creation_time = dateutil.parser.parse(gdalInfo.get("metadata", {}).get(metadata_keys[0], {}).get("creation_time", ""))
except dateutil.parser.ParserError:
creation_time = None
else:
description = "TIFF file"
creation_time = None
description = gdalInfo.get("metadata", {}).get("", {}).get("title", "TIFF file")
with rasterio.open(url) as dataset:

with rasterio.open(url) as dataset:
for v in zip(dataset.indexes, dataset.descriptions):
bands.append(Band(name="Band " + str(v[0]), common_name="Band " + str(v[0]), description=v[1] if v[1] else "Band " + str(v[0])))
# GET THE GEO EXTEND
# GET THE GEO EXTENT
# Read the dataset's valid data mask as a ndarray.
mask = dataset.dataset_mask()
# Extract feature shapes and values from the array.
Expand Down

0 comments on commit 1424b16

Please sign in to comment.