Files
2026-06-19 11:15:39 +02:00

25 lines
723 B
Python

import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
# 1. Load the interpolated CSV
df = pd.read_csv("out/interpolated_trace.csv", encoding='UTF-8', on_bad_lines='skip', delimiter=';') # or 'cp1252' if needed
# 2. Define your coordinate column names (replace if needed)
x_col = 'Lambert_X'
y_col = 'Lambert_Y'
# 3. Create geometry from X and Y
geometry = [Point(xy) for xy in zip(df[x_col], df[y_col])]
# 4. Create GeoDataFrame
gdf = gpd.GeoDataFrame(df, geometry=geometry)
# 5. Set CRS (Lambert 93 = EPSG:2154, common in France)
gdf.set_crs(epsg=2154, inplace=True)
# 6. Export to shapefile
gdf.to_file("out/interpolated_trace.shp")
print("✅ Shapefile created: interpolated_trace.shp")