修改植被物候流程
parent
4c743e6e19
commit
e42eedea0c
|
@ -28,6 +28,7 @@ from VegetationPhenologyAuxData import PhenoloyMeasCsv_geo
|
||||||
|
|
||||||
from tool.algorithm.xml.CreateMetaDict import CreateMetaDict, CreateProductXml
|
from tool.algorithm.xml.CreateMetaDict import CreateMetaDict, CreateProductXml
|
||||||
from tool.file.fileHandle import fileHandle
|
from tool.file.fileHandle import fileHandle
|
||||||
|
from tool.algorithm.algtools.ROIAlg import ROIAlg as roi
|
||||||
import sys
|
import sys
|
||||||
from tool.algorithm.transforml1a.transHandle import TransImgL1A
|
from tool.algorithm.transforml1a.transHandle import TransImgL1A
|
||||||
from tool.csv.csvHandle import csvHandle
|
from tool.csv.csvHandle import csvHandle
|
||||||
|
@ -47,7 +48,8 @@ logger = logging.getLogger("mylog")
|
||||||
FILTER_SIZE = int(cf.get('filter_size'))
|
FILTER_SIZE = int(cf.get('filter_size'))
|
||||||
MAX_TRAN_NUM = int(cf.get('max_tran__num_per_class'))
|
MAX_TRAN_NUM = int(cf.get('max_tran__num_per_class'))
|
||||||
file =fileHandle(DEBUG)
|
file =fileHandle(DEBUG)
|
||||||
env_str = os.path.split(os.path.realpath(__file__))[0]
|
# env_str = os.path.split(os.path.realpath(__file__))[0]
|
||||||
|
env_str =os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||||
os.environ['PROJ_LIB'] = env_str
|
os.environ['PROJ_LIB'] = env_str
|
||||||
class PhenologyMain:
|
class PhenologyMain:
|
||||||
"""
|
"""
|
||||||
|
@ -150,12 +152,13 @@ class PhenologyMain:
|
||||||
for name in self.__processing_paras['name_list']:
|
for name in self.__processing_paras['name_list']:
|
||||||
self.preprocess_single_tar(name, scopes_roi)
|
self.preprocess_single_tar(name, scopes_roi)
|
||||||
|
|
||||||
para_names_geo = [name + '_sim_ori']
|
para_names_geo = [name + '_sim_ori', 'Covering']
|
||||||
self.__feature_name_list = para_names_geo
|
self.__feature_name_list = para_names_geo
|
||||||
p = pp()
|
p = pp()
|
||||||
cutted_img_paths, scopes_roi = p.cut_geoimg(self.__workspace_preprocessing_path, para_names_geo,
|
cutted_img_paths, scopes_roi = p.cut_geoimg(self.__workspace_preprocessing_path, para_names_geo,
|
||||||
self.__processing_paras)
|
self.__processing_paras)
|
||||||
self.__preprocessed_paras.update({name + 'sim_ori': cutted_img_paths.get(name + '_sim_ori')})
|
self.__preprocessed_paras.update({name + '_sim_ori': cutted_img_paths.get(name + '_sim_ori')})
|
||||||
|
self.__preprocessed_paras.update({name + '_Covering': cutted_img_paths.get('Covering')})
|
||||||
logger.info('preprocess_handle success!')
|
logger.info('preprocess_handle success!')
|
||||||
logger.info('progress bar: 10%')
|
logger.info('progress bar: 10%')
|
||||||
|
|
||||||
|
@ -258,7 +261,7 @@ class PhenologyMain:
|
||||||
sim_ori_path = self.__preprocessed_paras[sim_ori_key]
|
sim_ori_path = self.__preprocessed_paras[sim_ori_key]
|
||||||
|
|
||||||
hh_path = self.__preprocessed_paras[name + "_HH"]
|
hh_path = self.__preprocessed_paras[name + "_HH"]
|
||||||
hh_geo_path = os.path.join(self.__workspace_processing_path, 'hh_geo.tif')
|
hh_geo_path = os.path.join(self.__workspace_processing_path, name.split('-')[0] + '_geo.tif')
|
||||||
paramter = self.__processing_paras[name + "paraMeter"]
|
paramter = self.__processing_paras[name + "paraMeter"]
|
||||||
self.calInterpolation_bil_Wgs84_rc_sar_sigma(paramter, sim_ori_path, hh_path, hh_geo_path)
|
self.calInterpolation_bil_Wgs84_rc_sar_sigma(paramter, sim_ori_path, hh_path, hh_geo_path)
|
||||||
|
|
||||||
|
@ -343,7 +346,7 @@ class PhenologyMain:
|
||||||
# 生成训练集
|
# 生成训练集
|
||||||
X_train_part, Y_train_part, optimal_feature = ml.gene_optimal_train_set(train_data_dic, feature_dir, 0.07, 0.85)
|
X_train_part, Y_train_part, optimal_feature = ml.gene_optimal_train_set(train_data_dic, feature_dir, 0.07, 0.85)
|
||||||
name_list = ml.get_name_list(feature_dir)
|
name_list = ml.get_name_list(feature_dir)
|
||||||
if optimal_feature == []:
|
if len(optimal_feature) <= 0:
|
||||||
logger.error('特征筛选结果为空,无可用特征作为训练集')
|
logger.error('特征筛选结果为空,无可用特征作为训练集')
|
||||||
continue
|
continue
|
||||||
# 生成测试集合
|
# 生成测试集合
|
||||||
|
@ -382,11 +385,19 @@ class PhenologyMain:
|
||||||
roi_img = self.imageHandler.get_band_array(self.create_roi(in_tif_paths[0]))
|
roi_img = self.imageHandler.get_band_array(self.create_roi(in_tif_paths[0]))
|
||||||
# 获取影像roi区域
|
# 获取影像roi区域
|
||||||
cover_data_pro = cover_data * roi_img
|
cover_data_pro = cover_data * roi_img
|
||||||
cover_geo_path = os.path.join(self.__product_dic, os.path.basename(product_path).split('.tif')[0] + '-VP.tif')
|
cover_geo_path = os.path.join(self.__workspace_processing_path, os.path.basename(product_path).split('.tif')[0] + '-VPtemp.tif')
|
||||||
self.imageHandler.write_img(cover_geo_path, proj_geo, geo_geo, cover_data_pro)
|
self.imageHandler.write_img(cover_geo_path, proj_geo, geo_geo, cover_data_pro)
|
||||||
self.imageHandler.write_quick_view(cover_geo_path, color_img=True)
|
|
||||||
|
|
||||||
meta_xml_path = self.create_meta_file(cover_geo_path)
|
self.resampleImgs(name, cover_geo_path)
|
||||||
|
para_names = ['Covering']
|
||||||
|
mask_dir = os.path.join(self.__workspace_processing_path, name + '\\')
|
||||||
|
bare_land_mask_path = roi().roi_process_VP(para_names, mask_dir,
|
||||||
|
self.__processing_paras, self.__preprocessed_paras, name)
|
||||||
|
product_path_pro = os.path.join(self.__product_dic, os.path.basename(product_path).split('.tif')[0] + '-VP.tif')
|
||||||
|
# 获取影像roi区域
|
||||||
|
roi.cal_roi(product_path_pro, cover_geo_path, bare_land_mask_path, background_value=0)
|
||||||
|
self.imageHandler.write_quick_view(product_path_pro, color_img=True)
|
||||||
|
meta_xml_path = self.create_meta_file(product_path_pro)
|
||||||
|
|
||||||
temp_folder = os.path.join(self.__workspace_path, EXE_NAME, 'Output')
|
temp_folder = os.path.join(self.__workspace_path, EXE_NAME, 'Output')
|
||||||
out_xml = os.path.join(temp_folder, os.path.basename(meta_xml_path))
|
out_xml = os.path.join(temp_folder, os.path.basename(meta_xml_path))
|
||||||
|
@ -511,6 +522,12 @@ class PhenologyMain:
|
||||||
|
|
||||||
return product_geo_path
|
return product_geo_path
|
||||||
|
|
||||||
|
def resampleImgs(self, name, refer_img_path):
|
||||||
|
|
||||||
|
cover_rampling_path = os.path.join(self.__workspace_processing_path, name + "_cover.tif")
|
||||||
|
pp.resampling_by_scale(self.__preprocessed_paras[name + "_Covering"], cover_rampling_path, refer_img_path)
|
||||||
|
self.__preprocessed_paras[name + "_Covering"] = cover_rampling_path
|
||||||
|
|
||||||
def create_roi(self, img_path):
|
def create_roi(self, img_path):
|
||||||
"""
|
"""
|
||||||
计算ROI掩膜
|
计算ROI掩膜
|
||||||
|
|
Loading…
Reference in New Issue