33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import sys
|
|
import os
|
|
os.environ["OGR_ORGANIZE_POLYGONS"] = "SKIP"
|
|
|
|
from pathlib import Path
|
|
import geopandas as gpd
|
|
|
|
|
|
# 添加项目根目录到路径
|
|
project_root = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
import app
|
|
from app.core import projection
|
|
from app.config.project_enum import CRS
|
|
|
|
input_folder = r"E:\@三普\@二普和测土配方样点处理\云南省"
|
|
output_folder = r"E:\@三普\@二普和测土配方样点处理\云南省_投影转换"
|
|
|
|
for root, dirs, files in os.walk(input_folder):
|
|
for file in files:
|
|
if file.endswith(".shp"):
|
|
input_path = os.path.join(root, file)
|
|
output_path = os.path.join(output_folder, os.path.relpath(input_path, input_folder))
|
|
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
|
|
gdf = gpd.read_file(input_path)
|
|
if gdf.crs is not None:
|
|
reproject_gdf = projection.reproject_gdf(gdf, auto_crs=True)
|
|
reproject_gdf.to_file(output_path)
|
|
print("Reprojected CRS:", reproject_gdf.crs)
|
|
else:
|
|
print("No CRS information found.") |