加入解压缩方法,解决正射输入为压缩包问题
parent
71839faef1
commit
2dc9e52974
|
@ -1,103 +0,0 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<Root>
|
||||
<TaskID>CSAR_202107275419_0001-0</TaskID>
|
||||
<WorkSpace>D:\micro\LWork\</WorkSpace>
|
||||
<AlgCompt>
|
||||
<DataTransModel>File</DataTransModel>
|
||||
<Artificial>ElementAlg</Artificial>
|
||||
<AlgorithmName>Ortho_C_SAR_V2.1</AlgorithmName>
|
||||
<DllName>Ortho_C_SAR_V2.1.exe</DllName>
|
||||
<ChsName>正射校正</ChsName>
|
||||
<AlgorithmDesc>微波卫星3-5级产品生产模型</AlgorithmDesc>
|
||||
<AlgorithmAlias>Ortho-C-SAR-V2.1-1</AlgorithmAlias>
|
||||
<Version>1.0</Version>
|
||||
<AlgorithmClass>辐射类产品_正射校正</AlgorithmClass>
|
||||
<AlgorithmLevel>4</AlgorithmLevel>
|
||||
<AlgoirthmID>Ortho_中科卫星应用德清研究院_2.1</AlgoirthmID>
|
||||
<Author>中科卫星应用德清研究院</Author>
|
||||
<Type>景-算法</Type>
|
||||
<InputTestFilePath>Ortho\\Input6</InputTestFilePath>
|
||||
<InputTestFileName>
|
||||
2599253_San_Francisco
|
||||
</InputTestFileName>
|
||||
<OutputTestFilePath>Ortho\\Output</OutputTestFilePath>
|
||||
<OutputTestFileName>
|
||||
</OutputTestFileName>
|
||||
<jdkVersion>1.8</jdkVersion>
|
||||
<algDevlanguage>python</algDevlanguage>
|
||||
<Environment>
|
||||
<IsCluster>0</IsCluster>
|
||||
<ClusterNum>0</ClusterNum>
|
||||
<OperatingSystem>Windows10</OperatingSystem>
|
||||
<CPU>4核</CPU>
|
||||
<Memory>8GB</Memory>
|
||||
<Storage>25GB</Storage>
|
||||
<NetworkCard>无需求</NetworkCard>
|
||||
<Bandwidth>无需求</Bandwidth>
|
||||
<GPU>无需求</GPU>
|
||||
</Environment>
|
||||
<Utility Satellite="GF3" Sensor="MSS" Resolution="1" />
|
||||
<Inputs ParameterNum="3">
|
||||
<Parameter>
|
||||
<ParaName>SLC</ParaName>
|
||||
<ParaChsName>SLC元文件</ParaChsName>
|
||||
<Description>原始SLC各相关文件和参数</Description>
|
||||
<ParaType>File</ParaType>
|
||||
<DataType>tar.gz</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>E:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966.tar.gz</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>False</EnMultipleChoice>
|
||||
<Control>File</Control>
|
||||
<InputType>Satellite</InputType>
|
||||
<InputNum>1</InputNum>
|
||||
<DateFrom>GF3A</DateFrom>
|
||||
</Parameter>
|
||||
<Parameter>
|
||||
<ParaName>DEM</ParaName>
|
||||
<ParaChsName>DEM数字高程影像</ParaChsName>
|
||||
<Description>30m分辨率DEM数字高程影像tif E:\MicroWorkspace\LT1B\LT230919\dem</Description>
|
||||
<ParaType>File</ParaType>
|
||||
<DataType>tif</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>E:\MicroWorkspace\LT1B\LT230919\DEM30m.tif</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>True</EnMultipleChoice>
|
||||
<Control>File</Control>
|
||||
<InputType>DEM</InputType>
|
||||
<InputNum>0</InputNum>
|
||||
<DateFrom>DEM</DateFrom>
|
||||
</Parameter>
|
||||
<Parameter>
|
||||
<ParaName>CorrectMethod</ParaName>
|
||||
<ParaChsName>选择校正方法</ParaChsName>
|
||||
<Description>1.RPC;2.RD</Description>
|
||||
<ParaType>int</ParaType>
|
||||
<DataType>int</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>2</ParaValue>
|
||||
<EnModification>True</EnModification>
|
||||
<EnMultipleChoice>True</EnMultipleChoice>
|
||||
<Control>UploadInput</Control>
|
||||
<InputType>Aux</InputType>
|
||||
<InputNum>0</InputNum>
|
||||
<DateFrom>Aux</DateFrom>
|
||||
</Parameter>
|
||||
</Inputs>
|
||||
<Outputs ParameterNum="1">
|
||||
<Parameter>
|
||||
<ParaName>OrthoProduct</ParaName>
|
||||
<ParaChsName>产品结果文件</ParaChsName>
|
||||
<Description>产品结果文件</Description>
|
||||
<ParaType>File</ParaType>
|
||||
<DataType>tar.gz</DataType>
|
||||
<ParaSource>Cal</ParaSource>
|
||||
<ParaValue>D:\micro\LWork\Ortho\Output\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-ortho.tar.gz</ParaValue>
|
||||
<MaxValue>DEFAULT</MaxValue>
|
||||
<MinValue>DEFAULT</MinValue>
|
||||
<OptionValue>DEFAULT</OptionValue>
|
||||
<NoDataValue>DEFAULT</NoDataValue>
|
||||
</Parameter>
|
||||
</Outputs>
|
||||
</AlgCompt>
|
||||
</Root>
|
|
@ -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、间接定位法求解行列坐标
|
||||
|
|
|
@ -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']):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue