44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import pandas as pd
|
|
import geopandas as gpd
|
|
import numpy as np
|
|
import os
|
|
import pyproj
|
|
import matplotlib.pyplot as plt
|
|
import plotly.express as px
|
|
import contextily as ctx
|
|
from shapely import line_interpolate_point, unary_union
|
|
from shapely.ops import linemerge
|
|
from shapely.geometry import Point, LineString
|
|
|
|
|
|
# === PARAMÈTRES ===
|
|
in_path = "in"
|
|
csv_file = "input.csv"
|
|
shapefile_name = "célé.shp"
|
|
|
|
riv_gdf = gpd.read_file(os.path.join(in_path, shapefile_name)).to_crs(epsg=2154)
|
|
unioned = unary_union(riv_gdf.geometry)
|
|
|
|
# Step 3: Linemerge to form continuous lines
|
|
merged = linemerge(unioned)
|
|
|
|
gdf_cele = gpd.GeoDataFrame({'geometry':[merged]},
|
|
geometry='geometry',
|
|
crs="EPSG:2154")
|
|
print(type(merged), merged)
|
|
|
|
print("###################################### riv_gdf.geometry")
|
|
print(gdf_cele.geometry)
|
|
|
|
# wgs84_to_l93 = pyproj.Transformer.from_crs("EPSG:4326", "EPSG:2154", always_xy=True)
|
|
# l93_to_wgs84 = pyproj.Transformer.from_crs("EPSG:2154", "EPSG:4326", always_xy=True)
|
|
|
|
# x_l93, y_l93 = wgs84_to_l93.transform(1.928223285366529, 44.5968489248117)
|
|
# point_proj = Point(x_l93, y_l93)
|
|
# actual_distance = riv_line.project(point_proj)
|
|
# print(actual_distance)
|
|
|
|
# actual_point = riv_line.interpolate(actual_distance)
|
|
# actual_point_prj = l93_to_wgs84.transform(actual_point.x, actual_point.y)
|
|
# print(actual_point_prj)
|