Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ff2c94df1 | ||
![]() |
db283b40a4 |
@ -8,14 +8,12 @@ import fiona
|
|||||||
from edt import edt
|
from edt import edt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import math
|
import math
|
||||||
from post_pro.trans_orthophoto import TransOrthophoto
|
|
||||||
|
|
||||||
|
|
||||||
class MergeTif:
|
class MergeTif:
|
||||||
def __init__(self, output_dir: str):
|
def __init__(self, output_dir: str):
|
||||||
self.output_dir = output_dir
|
self.output_dir = output_dir
|
||||||
self.logger = logging.getLogger('UAV_Preprocess.MergeTif')
|
self.logger = logging.getLogger('UAV_Preprocess.MergeTif')
|
||||||
self.trans_orthophoto = TransOrthophoto()
|
|
||||||
|
|
||||||
def merge_orthophoto(self, grid_lt):
|
def merge_orthophoto(self, grid_lt):
|
||||||
"""合并网格的正射影像"""
|
"""合并网格的正射影像"""
|
||||||
@ -55,9 +53,6 @@ class MergeTif:
|
|||||||
self.output_dir, "orthophoto.tif"), orthophoto_vars)
|
self.output_dir, "orthophoto.tif"), orthophoto_vars)
|
||||||
self.logger.info("所有产品合并完成")
|
self.logger.info("所有产品合并完成")
|
||||||
|
|
||||||
self.trans_orthophoto.trans_to_epsg4326(os.path.join(self.output_dir, "orthophoto.tif"), os.path.join(
|
|
||||||
self.output_dir, "orthophoto_epsg4326.tif"))
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"产品合并过程中发生错误: {str(e)}", exc_info=True)
|
self.logger.error(f"产品合并过程中发生错误: {str(e)}", exc_info=True)
|
||||||
raise
|
raise
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import argparse
|
||||||
import rasterio
|
import rasterio
|
||||||
from rasterio.warp import calculate_default_transform, reproject, Resampling
|
from rasterio.warp import calculate_default_transform, reproject, Resampling
|
||||||
|
|
||||||
@ -6,6 +7,8 @@ from rasterio.warp import calculate_default_transform, reproject, Resampling
|
|||||||
class TransOrthophoto:
|
class TransOrthophoto:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.logger = logging.getLogger('UAV_Preprocess.TransOrthophoto')
|
self.logger = logging.getLogger('UAV_Preprocess.TransOrthophoto')
|
||||||
|
logging.basicConfig(level=logging.INFO,
|
||||||
|
format='%(asctime)s %(levelname)s %(message)s')
|
||||||
|
|
||||||
def trans_to_epsg4326(self, ori_orthophoto_path: str, output_path: str):
|
def trans_to_epsg4326(self, ori_orthophoto_path: str, output_path: str):
|
||||||
# 打开原始文件
|
# 打开原始文件
|
||||||
@ -37,8 +40,13 @@ class TransOrthophoto:
|
|||||||
resampling=Resampling.nearest
|
resampling=Resampling.nearest
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger.info(f"文件已成功重投影")
|
self.logger.info(f"文件已成功重投影: {output_path}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
trans = TransOrthophoto()
|
parser = argparse.ArgumentParser(description="正射影像投影转换为EPSG:4326")
|
||||||
trans.trans_to_epsg4326(r"G:\ODM_output\test\orthophoto.tif", r"G:\ODM_output\test\orthophoto_epsg4326.tif")
|
parser.add_argument('--input_img', required=True, help='输入影像路径')
|
||||||
|
parser.add_argument('--output_img', required=True, help='输出影像路径')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
trans = TransOrthophoto()
|
||||||
|
trans.trans_to_epsg4326(args.input_img, args.output_img)
|
Loading…
Reference in New Issue
Block a user