修改轨迹图的坐标系
This commit is contained in:
parent
b69a610dd2
commit
697660b5b3
@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
import logging
|
||||
from typing import Optional
|
||||
from pyproj import Transformer
|
||||
|
||||
|
||||
class FilterVisualizer:
|
||||
@ -17,6 +18,25 @@ class FilterVisualizer:
|
||||
"""
|
||||
self.output_dir = output_dir
|
||||
self.logger = logging.getLogger('UAV_Preprocess.Visualizer')
|
||||
# 创建坐标转换器
|
||||
self.transformer = Transformer.from_crs(
|
||||
"EPSG:4326", # WGS84经纬度坐标系
|
||||
"EPSG:32649", # UTM49N
|
||||
always_xy=True
|
||||
)
|
||||
|
||||
def _convert_to_utm(self, lon: pd.Series, lat: pd.Series) -> tuple:
|
||||
"""
|
||||
将经纬度坐标转换为UTM坐标
|
||||
|
||||
Args:
|
||||
lon: 经度序列
|
||||
lat: 纬度序列
|
||||
|
||||
Returns:
|
||||
tuple: (x坐标, y坐标)
|
||||
"""
|
||||
return self.transformer.transform(lon, lat)
|
||||
|
||||
def visualize_filter_step(self,
|
||||
current_points: pd.DataFrame,
|
||||
@ -38,34 +58,40 @@ class FilterVisualizer:
|
||||
filtered_files = set(previous_points['file']) - set(current_points['file'])
|
||||
filtered_points = previous_points[previous_points['file'].isin(filtered_files)]
|
||||
|
||||
# 转换坐标到UTM
|
||||
current_x, current_y = self._convert_to_utm(current_points['lon'], current_points['lat'])
|
||||
filtered_x, filtered_y = self._convert_to_utm(filtered_points['lon'], filtered_points['lat'])
|
||||
|
||||
# 创建图形
|
||||
plt.rcParams['font.sans-serif']=['SimHei']#黑体
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
plt.figure(figsize=(20, 16))
|
||||
|
||||
# 绘制保留的点
|
||||
plt.scatter(current_points['lon'], current_points['lat'],
|
||||
color='blue', label='Retained Points',
|
||||
plt.scatter(current_x, current_y,
|
||||
color='blue', label='保留的点',
|
||||
alpha=0.6, s=50)
|
||||
|
||||
# 绘制被过滤的点
|
||||
if not filtered_points.empty:
|
||||
plt.scatter(filtered_points['lon'], filtered_points['lat'],
|
||||
color='red', marker='x', label='Filtered Points',
|
||||
plt.scatter(filtered_x, filtered_y,
|
||||
color='red', marker='x', label='过滤的点',
|
||||
alpha=0.6, s=100)
|
||||
|
||||
# 设置图形属性
|
||||
plt.title(f"GPS Points After {step_name}\n"
|
||||
f"(Filtered: {len(filtered_points)}, Retained: {len(current_points)})",
|
||||
plt.title(f"{step_name}后的GPS点\n"
|
||||
f"(过滤: {len(filtered_points)}, 保留: {len(current_points)})",
|
||||
fontsize=14)
|
||||
plt.xlabel("Longitude", fontsize=12)
|
||||
plt.ylabel("Latitude", fontsize=12)
|
||||
plt.xlabel("东向坐标 (米)", fontsize=12)
|
||||
plt.ylabel("北向坐标 (米)", fontsize=12)
|
||||
plt.grid(True)
|
||||
|
||||
# 添加统计信息
|
||||
stats_text = (
|
||||
f"Original Points: {len(previous_points)}\n"
|
||||
f"Filtered Points: {len(filtered_points)}\n"
|
||||
f"Remaining Points: {len(current_points)}\n"
|
||||
f"Filter Rate: {len(filtered_points)/len(previous_points)*100:.1f}%"
|
||||
f"原始点数: {len(previous_points)}\n"
|
||||
f"过滤点数: {len(filtered_points)}\n"
|
||||
f"保留点数: {len(current_points)}\n"
|
||||
f"过滤率: {len(filtered_points)/len(previous_points)*100:.1f}%"
|
||||
)
|
||||
plt.figtext(0.02, 0.02, stats_text, fontsize=10,
|
||||
bbox=dict(facecolor='white', alpha=0.8))
|
||||
|
Loading…
Reference in New Issue
Block a user