fix(DEM_SuPER): 修复DEM数据下载拼接逻辑bug.

This commit is contained in:
谢泓 2025-08-05 17:21:53 +08:00
parent bc6977ce11
commit e1997c102e

View File

@ -22,7 +22,7 @@ Step2: Process DEM data
-------------------------------------------------------------------------------
Authors: Hong Xie
Last Updated: 2025-07-03
Last Updated: 2025-08-05
===============================================================================
"""
@ -183,14 +183,14 @@ def process_granule(
dem.rio.write_crs("EPSG:4326", inplace=True)
dem.attrs["scale_factor"] = 1
dem_raster_list.append(dem)
if len(dem_raster_list) > 1:
if len(dem_raster_list) >= 1:
if name == "slope" or name == "aspect":
dem_mosaiced = mosaic_images(dem_raster_list, nodata=-9999)
else:
dem_mosaiced = mosaic_images(dem_raster_list, nodata=-32768)
if roi is not None and clip:
dem_mosaiced = clip_image(dem_mosaiced, roi)
dem_mosaiced.rio.to_raster(output_file, driver="COG", compress="DEFLATE")
if roi is not None and clip:
dem_mosaiced = clip_image(dem_mosaiced, roi, clip_by_box=True)
dem_mosaiced.rio.to_raster(output_file, driver="COG", compress="DEFLATE")
except Exception as e:
logging.error(f"Error processing files in {name}: {e}")
return False
@ -211,6 +211,7 @@ def main(region: list, asset_name: list, tile_id: str):
unzip_dir = os.path.join(download_dir, "UNZIP")
output_dir = os.path.join(output_root_dir, "TIF", tile_id)
os.makedirs(unzip_dir, exist_ok=True)
os.makedirs(output_dir, exist_ok=True)
results_urls_file = f"{output_root_dir}\\NASADEM_{tile_id}_results_urls.json"
if not os.path.isfile(results_urls_file):
results_urls = earthdata_search(asset_name, roi=bbox)