Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add metadata to tiff files #103

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions earthspy/earthspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,13 @@ def get_available_data(self) -> list:
# and update service_url if dowload failed
try:
# store metadata of available scenes
self.metadata = [list(iterator) for iterator in search_iterator]

self.metadata = {}
for iterator in search_iterator:
iterator_list = list(iterator)
if len(iterator_list) > 0:
date = iterator_list[0]["properties"]["datetime"].split("T")[0]
self.metadata[date] = iterator_list

except shb.exceptions.DownloadFailedException:
# set specific base URL of deployment
self.catalog_config.sh_base_url = shb.DataCollection[
Expand All @@ -250,8 +255,13 @@ def get_available_data(self) -> list:
]

# store metadata of available scenes
self.metadata = [list(iterator) for iterator in search_iterator]

self.metadata = {}
for iterator in search_iterator:
iterator_list = list(iterator)
if len(iterator_list) > 0:
date = iterator_list[0]["properties"]["datetime"].split("T")[0]
self.metadata[date] = iterator_list

# create date +-1 hour around acquisition time
time_difference = timedelta(hours=1)

Expand Down Expand Up @@ -1061,11 +1071,11 @@ def merge_rasters(self) -> None:
"transform": output_transform,
}
)

id_dict = {k:self.metadata[date][0][k] for k in ["id"]}
# write mosaic
with rasterio.open(date_output_filename, "w", **output_meta) as dst:
dst.write(mosaic)

dst.update_tags(**id_dict)
# save file name of merged raster
self.output_filenames_renamed.append(date_output_filename)

Expand Down
Loading