refactor(raw_to_cog): 简化主函数参数并更新示例调用.
This commit is contained in:
parent
c82b58e91d
commit
d7cbf1e5f5
@ -8,7 +8,7 @@ COG (Cloud Optimized GeoTIFF) 是一种优化设计的 GeoTIFF 文件格式, 特
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Authors: CVEO Team
|
||||
Last Updated: 2026-01-28
|
||||
Last Updated: 2026-01-30
|
||||
===============================================================================
|
||||
"""
|
||||
|
||||
@ -105,15 +105,13 @@ def tif_to_cog(
|
||||
return
|
||||
|
||||
|
||||
def main(input_dir, file_name, output_path, output_type=gdal.GDT_Float32):
|
||||
input_dir = Path(input_dir)
|
||||
output_dir = Path(output_path)
|
||||
def main(input_path, output_path, output_type=gdal.GDT_Float32):
|
||||
input_path = Path(input_path)
|
||||
output_dir = Path(output_path).parent
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
# 配置日志记录
|
||||
log_file = output_dir / "toCOG.log"
|
||||
setup_logging(str(log_file))
|
||||
input_path = input_dir / file_name
|
||||
output_path = output_dir / file_name
|
||||
# 关于无效值
|
||||
# Float32 类型可以设为 -9999
|
||||
if output_type == gdal.GDT_Float32:
|
||||
@ -125,8 +123,10 @@ def main(input_dir, file_name, output_path, output_type=gdal.GDT_Float32):
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 输入目录: 包含分块tif影像的根目录
|
||||
input_root = Path(r"D:\CVEOdata\RS_Data\Terrain")
|
||||
file_name = "GLO30.DSM.2014.Hubei.30m.tif"
|
||||
# input_root = Path(r"D:\CVEOdata\RS_Data\Terrain")
|
||||
# 输出目录: 存放最终COG结果的目录
|
||||
output_root = Path(r"D:\CVEOdata\RS_Data\Terrain\COG")
|
||||
main(input_root, file_name, output_root)
|
||||
# output_root = Path(r"D:\CVEOdata\RS_Data\Terrain")
|
||||
input_path = input_root / "GLO30.DSM.2014.Hubei.30m.tif"
|
||||
output_path = output_root / "GLO30.DSM.2014.Hubei.30m.tif"
|
||||
# output_type = gdal.GDT_Float32
|
||||
# main(input_path, output_path, output_type)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user