From e27e358610d368195b50b16b12405077d598e3f9 Mon Sep 17 00:00:00 2001 From: tian jiax <446100073@qq.com> Date: Sat, 31 Aug 2024 15:44:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E5=90=91=E6=95=A3?= =?UTF-8?q?=E5=B0=84=E7=B3=BB=E6=95=B0=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=85=8D?= =?UTF-8?q?=E5=87=86=E5=86=85=E5=AD=98=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ortho/OrthoMain.spec | 22 +++++++++++++++ backScattering/BackScatteringMain.py | 4 ++- backScattering/BackScatteringMain.spec | 22 +++++++++++++++ landcover-S-SAR/LandCover-S-SAR.xml | 8 +++--- soilMoisture-S-SAR/SoilMoistureMain.py | 2 +- soilMoisture-S-SAR/SoilMoistureMain.spec | 22 +++++++++++++++ tool/algorithm/algtools/PreProcess.py | 34 ++++++++++++++++++++++++ tool/algorithm/image/ImageHandle.py | 7 ++++- 8 files changed, 114 insertions(+), 7 deletions(-) diff --git a/Ortho/OrthoMain.spec b/Ortho/OrthoMain.spec index 9aab8aa..b9503b2 100644 --- a/Ortho/OrthoMain.spec +++ b/Ortho/OrthoMain.spec @@ -1,6 +1,28 @@ # -*- mode: python ; coding: utf-8 -*- +import sys +from shutil import copy +import os +cwdpath = os.getcwd() +toolDir = os.path.join(cwdpath, 'tool') +if os.path.exists(toolDir): + os.remove(toolDir) +os.mkdir(toolDir) +source_folder = '../tool' +def copy_file(path_read, path_write): + names = os.listdir(path_read) + for name in names: + path_read_new = os.path.join(path_read, name) + path_write_new = os.path.join(path_write, name) + if os.path.isdir(path_read_new): + if not os.path.exists(path_write_new): + os.mkdir(path_write_new) + copy_file(path_read_new, path_write_new) + else: + copy(path_read_new, path_write_new) + +copy_file(source_folder, toolDir) block_cipher = None diff --git a/backScattering/BackScatteringMain.py b/backScattering/BackScatteringMain.py index d883ffc..1bbad42 100644 --- a/backScattering/BackScatteringMain.py +++ b/backScattering/BackScatteringMain.py @@ -300,6 +300,7 @@ class ScatteringMain: # 对映射表进行校正 sim_ori_tiff = out_dir_path + "\\" + "RD_sim_ori.tif" out_sim_ori = out_dir_path + "\\" + "sim_ori-ortho.tif" + out_sim_ori_temp = self.__workspace_baseMap_path + "\\" + "sim_ori-ortho.tif" parameter_path = os.path.join(self.__workspace_processing_path, "orth_para.txt") in_tif_paths = list(glob.glob(os.path.join(slc_paths, '*.tiff'))) out_rpc_db = os.path.join(self.__workspace_baseMap_path, 'rpc_line.tif') @@ -335,7 +336,8 @@ class ScatteringMain: lon_new = im_geotrans[0] + x lat_new = im_geotrans[3] - y im_geosNew = [lon_new, im_geotrans[1], im_geotrans[2], lat_new, im_geotrans[4], im_geotrans[5]] - ImageHandler().write_img(out_sim_ori, im_proj, im_geosNew, im_arr) + ImageHandler().write_img(out_sim_ori_temp, im_proj, im_geosNew, im_arr) + pp.resample_by_gdal(out_sim_ori_temp, out_sim_ori) # todo 重采样为方像元 os.remove(sim_ori_tiff) return out_sim_ori diff --git a/backScattering/BackScatteringMain.spec b/backScattering/BackScatteringMain.spec index 73405a6..b7b45da 100644 --- a/backScattering/BackScatteringMain.spec +++ b/backScattering/BackScatteringMain.spec @@ -1,6 +1,28 @@ # -*- mode: python ; coding: utf-8 -*- +import sys +from shutil import copy +import os +cwdpath = os.getcwd() +toolDir = os.path.join(cwdpath, 'tool') +if os.path.exists(toolDir): + os.remove(toolDir) +os.mkdir(toolDir) +source_folder = '../tool' +def copy_file(path_read, path_write): + names = os.listdir(path_read) + for name in names: + path_read_new = os.path.join(path_read, name) + path_write_new = os.path.join(path_write, name) + if os.path.isdir(path_read_new): + if not os.path.exists(path_write_new): + os.mkdir(path_write_new) + copy_file(path_read_new, path_write_new) + else: + copy(path_read_new, path_write_new) + +copy_file(source_folder, toolDir) block_cipher = None diff --git a/landcover-S-SAR/LandCover-S-SAR.xml b/landcover-S-SAR/LandCover-S-SAR.xml index 38dfcf6..72f12a6 100644 --- a/landcover-S-SAR/LandCover-S-SAR.xml +++ b/landcover-S-SAR/LandCover-S-SAR.xml @@ -38,7 +38,7 @@ File tar.gz Man - F:\MicroWorkspace\20240814tw\HJ2E_KRN_QPS_008852_E110.6_N20.1_20240515_SLC_AHV_L10000208028-Ortho.tar.gz + F:\MicroWorkspace\S_SAR\AHV\HJ2E_MYC_QPS_001752_E118.0_N37.7_20230204_SLC_AHV_L10000010458-Ortho.tar.gz True False File @@ -51,9 +51,9 @@ 标记数据 标记的样本数据 File - csv + zip Man - F:\MicroWorkspace\20240814tw\LandCover.csv + F:\al_zhongji\S-SAR-data\landCover\SSAR_landcover_landaCoverSample.zip True True UploadInput @@ -103,7 +103,7 @@ File tar.gz Man - D:\micro\SWork\LandCover\Output\HJ2E_KRN_QPS_008852_E110.6_N20.1_20240515_SLC_AHV_L10000208028-Ortho-LANDCLASS.tar.gz + D:\micro\SWork\LandCover\Output\HJ2E_MYC_QPS_001752_E118.0_N37.7_20230204_SLC_AHV_L10000010458-Ortho-LANDCLASS.tar.gz diff --git a/soilMoisture-S-SAR/SoilMoistureMain.py b/soilMoisture-S-SAR/SoilMoistureMain.py index b638cae..a60b278 100644 --- a/soilMoisture-S-SAR/SoilMoistureMain.py +++ b/soilMoisture-S-SAR/SoilMoistureMain.py @@ -386,7 +386,7 @@ class MoistureMain: # data[data > soil_moisture_value_max] = soil_moisture_value_max data[data < soil_moisture_value_min] = -9999 data[data > soil_moisture_value_max] = -9999 - self.imageHandler.write_img(product_path, proj, geos, data) + self.imageHandler.write_img(product_path, proj, geos, data, '-9999') # 生成快视图 self.imageHandler.write_quick_view(product_path) diff --git a/soilMoisture-S-SAR/SoilMoistureMain.spec b/soilMoisture-S-SAR/SoilMoistureMain.spec index 643578a..8b24ba7 100644 --- a/soilMoisture-S-SAR/SoilMoistureMain.spec +++ b/soilMoisture-S-SAR/SoilMoistureMain.spec @@ -1,6 +1,28 @@ # -*- mode: python ; coding: utf-8 -*- +import sys +from shutil import copy +import os +cwdpath = os.getcwd() +toolDir = os.path.join(cwdpath, 'tool') +if os.path.exists(toolDir): + os.remove(toolDir) +os.mkdir(toolDir) +source_folder = '../tool' +def copy_file(path_read, path_write): + names = os.listdir(path_read) + for name in names: + path_read_new = os.path.join(path_read, name) + path_write_new = os.path.join(path_write, name) + if os.path.isdir(path_read_new): + if not os.path.exists(path_write_new): + os.mkdir(path_write_new) + copy_file(path_read_new, path_write_new) + else: + copy(path_read_new, path_write_new) + +copy_file(source_folder, toolDir) block_cipher = None diff --git a/tool/algorithm/algtools/PreProcess.py b/tool/algorithm/algtools/PreProcess.py index e9b9155..d8d64ea 100644 --- a/tool/algorithm/algtools/PreProcess.py +++ b/tool/algorithm/algtools/PreProcess.py @@ -276,6 +276,40 @@ class PreProcess: logger.error('shapely.geos.TopologicalError occurred!') return + @staticmethod + def resample_by_gdal(in_path, out_path): + src_ds = gdal.Open(in_path, gdal.GA_ReadOnly) + + # 设置目标影像的投影和范围 + target_projection = src_ds.GetProjection() + target_geotransform = src_ds.GetGeoTransform() + + x_scale = target_geotransform[1] + y_scale = target_geotransform[5] + scale = [x_scale, np.abs(y_scale)] + new_scale = np.max(scale) + + dst_geotransform = [target_geotransform[0], new_scale, target_geotransform[2], target_geotransform[3], + target_geotransform[4], -new_scale] + target_x_size = int(src_ds.RasterXSize * x_scale / new_scale) # 假设我们要将影像大小缩小到原来的一半 + target_y_size = int(src_ds.RasterYSize * np.abs(y_scale) / new_scale) + + # 创建输出驱动 + driver = gdal.GetDriverByName('GTiff') + + # 创建输出文件 + dst_ds = driver.Create(out_path, target_x_size, target_y_size, src_ds.RasterCount, + src_ds.GetRasterBand(1).DataType) + dst_ds.SetGeoTransform(dst_geotransform) + dst_ds.SetProjection(target_projection) + + # 执行重采样 + gdal.ReprojectImage(src_ds, dst_ds, None, None, gdal.GRA_Bilinear) # 使用双线性插值 + + # 关闭数据集 + dst_ds = None + src_ds = None + @staticmethod def write_polygon_shp(out_shp_path, point_list, EPSG =32649): diff --git a/tool/algorithm/image/ImageHandle.py b/tool/algorithm/image/ImageHandle.py index 82b3d8e..9c641bb 100644 --- a/tool/algorithm/image/ImageHandle.py +++ b/tool/algorithm/image/ImageHandle.py @@ -693,7 +693,12 @@ class ImageHandler: img_col_start = x_split * 1 img_col_end = x_split * 3 img_row_start = y_split * 1 - img_row_end = y_split *3 + img_row_end = y_split * 3 + cols = img_col_end - img_col_start + rows = img_row_end - img_row_start + if cols > 10000 or rows > 10000: + img_col_end = img_col_start + 10000 + img_row_end = img_row_start + 10000 point_upleft = self.trans_rowcol2geo(img_geotrans, img_col_start, img_row_start) point_upright = self.trans_rowcol2geo(img_geotrans, img_col_end, img_row_start)