From 2dc9e52974baa2cc309b80a8f3b3aee128d5e5ae Mon Sep 17 00:00:00 2001 From: cuiyyyu <1748614422@qq.com> Date: Tue, 23 Jan 2024 18:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=A7=A3=E5=8E=8B=E7=BC=A9?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=AD=A3=E5=B0=84?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E4=B8=BA=E5=8E=8B=E7=BC=A9=E5=8C=85=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ortho-L-SAR/Ortho-L-SAR.xml | 103 --------------------------- Ortho-L-SAR/OrthoMain.py | 17 ++++- tool/algorithm/block/blockprocess.py | 33 +++++++++ 3 files changed, 49 insertions(+), 104 deletions(-) delete mode 100644 Ortho-L-SAR/Ortho-L-SAR.xml diff --git a/Ortho-L-SAR/Ortho-L-SAR.xml b/Ortho-L-SAR/Ortho-L-SAR.xml deleted file mode 100644 index d18f5b5..0000000 --- a/Ortho-L-SAR/Ortho-L-SAR.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - CSAR_202107275419_0001-0 - D:\micro\LWork\ - - File - ElementAlg - Ortho_C_SAR_V2.1 - Ortho_C_SAR_V2.1.exe - 正射校正 - 微波卫星3-5级产品生产模型 - Ortho-C-SAR-V2.1-1 - 1.0 - 辐射类产品_正射校正 - 4 - Ortho_中科卫星应用德清研究院_2.1 - 中科卫星应用德清研究院 - 景-算法 - Ortho\\Input6 - - 2599253_San_Francisco - - Ortho\\Output - - - 1.8 - python - - 0 - 0 - Windows10 - 4核 - 8GB - 25GB - 无需求 - 无需求 - 无需求 - - - - - SLC - SLC元文件 - 原始SLC各相关文件和参数 - File - tar.gz - Cal - E:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966.tar.gz - True - False - File - Satellite - 1 - GF3A - - - DEM - DEM数字高程影像 - 30m分辨率DEM数字高程影像tif E:\MicroWorkspace\LT1B\LT230919\dem - File - tif - Cal - E:\MicroWorkspace\LT1B\LT230919\DEM30m.tif - True - True - File - DEM - 0 - DEM - - - CorrectMethod - 选择校正方法 - 1.RPC;2.RD - int - int - Cal - 2 - True - True - UploadInput - Aux - 0 - Aux - - - - - OrthoProduct - 产品结果文件 - 产品结果文件 - File - tar.gz - Cal - D:\micro\LWork\Ortho\Output\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-ortho.tar.gz - DEFAULT - DEFAULT - DEFAULT - DEFAULT - - - - \ No newline at end of file diff --git a/Ortho-L-SAR/OrthoMain.py b/Ortho-L-SAR/OrthoMain.py index d73878a..ab58d9b 100644 --- a/Ortho-L-SAR/OrthoMain.py +++ b/Ortho-L-SAR/OrthoMain.py @@ -9,6 +9,8 @@ @Version :1.0.0 """ import logging + +from tool.algorithm.block.blockprocess import BlockProcess from tool.algorithm.image.ImageHandle import ImageHandler from tool.algorithm.xml.CreateMetaDict import CreateMetaDict, CreateProductXml from tool.algorithm.algtools.PreProcess import PreProcess as pp @@ -298,6 +300,19 @@ class OrthoMain: shutil.copy(file_path, os.path.join(dem_path, tif_name)) para_path = os.path.join(self.__workspace_origin_path,para['ParaName']) processing_paras.update({name: para_path}) + if para['DataType'] == 'zip': + if para['ParaValue'] != 'empty' and para['ParaValue'] != 'Empty' and para['ParaValue'] != '': + para_path_list = para['ParaValue'].split(";") + if len(para_path_list) != 0: + dem_path = os.path.join(self.__workspace_origin_path, para['ParaName']) + if os.path.exists(dem_path) is False: + os.mkdir(dem_path) + for file_path in para_path_list: + temp = BlockProcess.unzip_file(file_path, dem_path) + # tif_name = os.path.basename(file_path) + # shutil.copy(file_path, os.path.join(dem_path, tif_name)) + para_path = os.path.join(self.__workspace_origin_path,para['ParaName'],os.path.basename(os.path.dirname(temp))) + processing_paras.update({name: para_path}) elif para['ParaType'] == 'Value': if para['DataType'] == 'float': value = float(para['ParaValue']) @@ -539,7 +554,7 @@ class OrthoMain: in_dem_path = self.__in_processing_paras['DEM'] meta_file_path = self.__in_processing_paras['META'] # .meta文件路径 out_dem_path = self.__workspace_ResampledDEM_path - dem_merged_path=DEMProcess.dem_merged(in_dem_path, meta_file_path, out_dem_path) # 生成TestDEM\mergedDEM_VRT.tif + dem_merged_path = DEMProcess.dem_merged(in_dem_path, meta_file_path, out_dem_path) # 生成TestDEM\mergedDEM_VRT.tif # self.cut_dem(dem_merged_path, meta_file_path) # 2、间接定位法求解行列坐标 diff --git a/tool/algorithm/block/blockprocess.py b/tool/algorithm/block/blockprocess.py index 63b8a9b..b7794e9 100644 --- a/tool/algorithm/block/blockprocess.py +++ b/tool/algorithm/block/blockprocess.py @@ -8,6 +8,9 @@ @Date:2021/9/6 @Version:1.0.0 """ +import glob +import zipfile + from osgeo import osr, gdal import numpy as np import os @@ -39,7 +42,37 @@ class BlockProcess: suffix = '_' + name.split('_')[-4] + '_' + name.split('_')[-3] + '_' + name.split('_')[-2] + '_' + \ name.split('_')[-1] return suffix + @staticmethod + def unzip_file(zip_file_path, out_path): # ): + # 获取压缩文件所在的目录 + # extract_folder = os.path.dirname(zip_file_path) + if zip_file_path.endswith("dem.zip"): + out_path_merg = os.path.join(out_path) + # os.mkdir(out_path_merg) + para_value_list = zip_file_path.split(";") + for n in para_value_list: + with zipfile.ZipFile(n, 'r') as zip_ref: + # 解压到和压缩文件同名的文件夹中 + zip_ref.extractall(out_path_merg) + + return out_path + + else: + basename = os.path.splitext(os.path.basename(zip_file_path))[0] + extract_folder = os.path.join(out_path, basename) + + with zipfile.ZipFile(zip_file_path, 'r') as zip_ref: + # 解压到和压缩文件同名的文件夹中 + zip_ref.extractall(extract_folder) + + files = list(glob.glob(os.path.join(extract_folder, '*'))) + for file in files: + if basename in os.path.basename(file): + if not file.endswith(".xml"): + unzipped_folder_path = file + + return unzipped_folder_path @staticmethod def get_file_names(data_dir, file_type=['tif', 'tiff']): """