diff --git a/.ipynb_checkpoints/data_analysis_functions-checkpoint.py b/.ipynb_checkpoints/data_analysis_functions-checkpoint.py index 5de8242..c639583 100644 --- a/.ipynb_checkpoints/data_analysis_functions-checkpoint.py +++ b/.ipynb_checkpoints/data_analysis_functions-checkpoint.py @@ -7,6 +7,7 @@ import branca from IPython.display import display from scipy.spatial import cKDTree from geopy.distance import geodesic +import numpy as np def plot_univariate_variable_analysis( @@ -213,4 +214,37 @@ def plot_univariate_variable_analysis( plt.title(f"{variable_name} Distribution (Boxplot)") plt.ylabel(variable_name) plt.show() - + +def compute_distances(df, tree_index): + """ + Computes distances between a specific tree and all other trees in the DataFrame. + + Args: + df: DataFrame containing tree data with 'geo_point_2d_a' (longitude) and 'geo_point_2d_b' (latitude) columns. + tree_index: Index of the specific tree in the DataFrame. + + Returns: + A pandas Series containing distances to all other trees from the specified tree. + Returns None if the tree_index is out of range or if necessary columns are missing. + """ + + # Safety checks + if not all(col in df.columns for col in ['geo_point_2d_a', 'geo_point_2d_b']): + print("Error: 'geo_point_2d_a' or 'geo_point_2d_b' columns not found in DataFrame.") + return None + + if tree_index not in df.index: + print(f"Error: tree_index {tree_index} is out of range.") + return None + + # Get coordinates of the chosen tree + tree_coords = (df.loc[tree_index, 'geo_point_2d_a'], df.loc[tree_index, 'geo_point_2d_b']) + + # Calculate distances to all other trees + distances = [] + for index, row in df.iterrows(): + other_tree_coords = (row['geo_point_2d_a'], row['geo_point_2d_b']) # Assuming latitude, longitude order + distance = geodesic(tree_coords, other_tree_coords).meters + distances.append(distance) + + return pd.Series(distances, index=df.index) # Use original index diff --git a/Paris_trees_analysis.ipynb b/Paris_trees_analysis.ipynb index bdd5a68..07d020f 100644 --- a/Paris_trees_analysis.ipynb +++ b/Paris_trees_analysis.ipynb @@ -3342,7 +3342,9 @@ "cell_type": "code", "execution_count": 83, "id": "c1d63cdf-8e99-4f05-87cf-f3a06b0af3dc", - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "data": { diff --git a/data_analysis_functions.py b/data_analysis_functions.py index 5de8242..c639583 100644 --- a/data_analysis_functions.py +++ b/data_analysis_functions.py @@ -7,6 +7,7 @@ import branca from IPython.display import display from scipy.spatial import cKDTree from geopy.distance import geodesic +import numpy as np def plot_univariate_variable_analysis( @@ -213,4 +214,37 @@ def plot_univariate_variable_analysis( plt.title(f"{variable_name} Distribution (Boxplot)") plt.ylabel(variable_name) plt.show() - + +def compute_distances(df, tree_index): + """ + Computes distances between a specific tree and all other trees in the DataFrame. + + Args: + df: DataFrame containing tree data with 'geo_point_2d_a' (longitude) and 'geo_point_2d_b' (latitude) columns. + tree_index: Index of the specific tree in the DataFrame. + + Returns: + A pandas Series containing distances to all other trees from the specified tree. + Returns None if the tree_index is out of range or if necessary columns are missing. + """ + + # Safety checks + if not all(col in df.columns for col in ['geo_point_2d_a', 'geo_point_2d_b']): + print("Error: 'geo_point_2d_a' or 'geo_point_2d_b' columns not found in DataFrame.") + return None + + if tree_index not in df.index: + print(f"Error: tree_index {tree_index} is out of range.") + return None + + # Get coordinates of the chosen tree + tree_coords = (df.loc[tree_index, 'geo_point_2d_a'], df.loc[tree_index, 'geo_point_2d_b']) + + # Calculate distances to all other trees + distances = [] + for index, row in df.iterrows(): + other_tree_coords = (row['geo_point_2d_a'], row['geo_point_2d_b']) # Assuming latitude, longitude order + distance = geodesic(tree_coords, other_tree_coords).meters + distances.append(distance) + + return pd.Series(distances, index=df.index) # Use original index diff --git a/map_arrondissement.html b/map_arrondissement.html new file mode 100644 index 0000000..15b990a --- /dev/null +++ b/map_arrondissement.html @@ -0,0 +1,727 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/map_lieu.html b/map_lieu.html new file mode 100644 index 0000000..a7241af --- /dev/null +++ b/map_lieu.html @@ -0,0 +1,159335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/soutenance_projet2.pptx b/soutenance_projet2.pptx new file mode 100644 index 0000000..e6896fa Binary files /dev/null and b/soutenance_projet2.pptx differ