diff --git a/earthspy/earthspy.py b/earthspy/earthspy.py index de6581d..0296aba 100644 --- a/earthspy/earthspy.py +++ b/earthspy/earthspy.py @@ -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[ @@ -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) @@ -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)