From 79778dc57726a4979666d6e6012ae03b7302a526 Mon Sep 17 00:00:00 2001 From: xhong Date: Fri, 24 Apr 2026 18:09:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(raw=5Fto=5Fcog):=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=A1=BA=E5=BA=8F=E5=B9=B6=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将导入语句按标准顺序重新排列(标准库、第三方库、本地模块) - 移除 tif_to_cog 函数中未使用的 scaleParams 参数 - 更新示例代码中的测试路径和输出数据类型 - 更新文件最后修改日期 --- utils/raw_to_cog.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils/raw_to_cog.py b/utils/raw_to_cog.py index bdc356b..33f9800 100644 --- a/utils/raw_to_cog.py +++ b/utils/raw_to_cog.py @@ -8,16 +8,17 @@ COG (Cloud Optimized GeoTIFF) 是一种优化设计的 GeoTIFF 文件格式, 特 ------------------------------------------------------------------------------- Authors: CVEO Team -Last Updated: 2026-02-03 +Last Updated: 2026-04-22 =============================================================================== """ +import logging import os import sys -import logging from pathlib import Path -from osgeo import gdal + import numpy as np +from osgeo import gdal # 添加父目录到 sys.path 以导入 utils BASE_DIR = Path(__file__).parent.parent @@ -74,7 +75,6 @@ def tif_to_cog( output_type: int = gdal.GDT_Float32, no_data: float = np.nan, compress: str = "DEFLATE", - scaleParams: list = None, ): """ 将传统 GeoTIFF 转换为 COG 格式 @@ -205,9 +205,10 @@ def main(input_path, output_path, output_type=gdal.GDT_Float32): if __name__ == "__main__": # 输入目录: 包含分块tif影像的根目录 - input_root = Path(r"D:\CVEOdata\RS_Data\Terrain") + input_root = Path(r"D:\CVEOdata\RS_Data\Terrain\test") # 输出目录: 存放最终COG结果的目录 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_Byte + output_type = gdal.GDT_Float32 + main(input_path, output_path, output_type)