import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import matplotlib.pyplot as plt from preprocess.gps_extractor import GPSExtractor DATASET = r'F:\error_data\20240930091614\project\images' if __name__ == '__main__': extractor = GPSExtractor(DATASET) gps_points = extractor.extract_all_gps() # 创建两个子图 fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 8)) # 左图:原始散点图 ax1.scatter(gps_points['lon'], gps_points['lat'], color='blue', marker='o', label='GPS Points') ax1.set_title("GPS Coordinates of Images", fontsize=14) ax1.set_xlabel("Longitude", fontsize=12) ax1.set_ylabel("Latitude", fontsize=12) ax1.grid(True) ax1.legend() # # 右图:按时间排序的轨迹图 # gps_points_sorted = gps_points.sort_values('date') # # 绘制飞行轨迹线 # ax2.plot(gps_points_sorted['lon'][300:600], gps_points_sorted['lat'][300:600], # color='blue', linestyle='-', linewidth=1, alpha=0.6) # # 绘制GPS点 # ax2.scatter(gps_points_sorted['lon'][300:600], gps_points_sorted['lat'][300:600], # color='red', marker='o', s=30, label='GPS Points') # 标记起点和终点 # ax2.scatter(gps_points_sorted['lon'].iloc[0], gps_points_sorted['lat'].iloc[0], # color='green', marker='^', s=100, label='Start') # ax2.scatter(gps_points_sorted['lon'].iloc[-1], gps_points_sorted['lat'].iloc[-1], # color='purple', marker='s', s=100, label='End') ax2.set_title("UAV Flight Trajectory", fontsize=14) ax2.set_xlabel("Longitude", fontsize=12) ax2.set_ylabel("Latitude", fontsize=12) ax2.grid(True) ax2.legend() # 调整子图之间的间距 plt.tight_layout() plt.show()