Commit 0f23647c authored by Eric Duminil's avatar Eric Duminil
Browse files

Trees open data : More information in table.

parent 3a54eeb7
...@@ -38,18 +38,27 @@ else: ...@@ -38,18 +38,27 @@ else:
df = pd.read_parquet(INPUT_FILE, engine='fastparquet') df = pd.read_parquet(INPUT_FILE, engine='fastparquet')
interactive_map = folium.Map()
species = 'species_latin' species = 'species_latin'
coordinates = ['latitude', 'longitude'] coordinates = ['latitude', 'longitude']
interesting_columns = ['tree_number', 'species_latin', 'latitude', 'longitude'] interesting_columns = ['tree_number', 'species_latin', 'latitude', 'longitude']
lat_min, lon_min, lat_max, lon_max = df[coordinates].agg(['min', 'max']).stack().values lat_min, lon_min, lat_max, lon_max = df[coordinates].agg(['min', 'max']).stack().values
interactive_map = folium.Map()
interactive_map.fit_bounds([(lat_min, lon_min), (lat_max, lon_max)]) interactive_map.fit_bounds([(lat_min, lon_min), (lat_max, lon_max)])
for same, grouped_df in df[interesting_columns].drop_duplicates().groupby(species): for same, grouped_df in df.groupby('tree_number'):
for row in grouped_df.itertuples(): tree = grouped_df.iloc[0]
table = grouped_df.drop(coordinates, axis=1).describe().to_html()
tree_id = tree['tree_number']
lat = tree['latitude']
lon = tree['longitude']
species = tree['species_latin']
species_de = tree['species_german']
soil = tree['soil_composition']
times = grouped_df['timestamp'].agg(['min', 'max'])
folium.Circle( folium.Circle(
location=[row.latitude, row.longitude], location=[lat, lon],
tooltip=row.species_latin, tooltip=f"{species} ({species_de})",
radius=50, # [m] radius=50, # [m]
color="black", color="black",
weight=1, weight=1,
...@@ -57,7 +66,8 @@ for same, grouped_df in df[interesting_columns].drop_duplicates().groupby(specie ...@@ -57,7 +66,8 @@ for same, grouped_df in df[interesting_columns].drop_duplicates().groupby(specie
opacity=1, opacity=1,
fill_color="green", fill_color="green",
fill=False, # gets overridden by fill_color fill=False, # gets overridden by fill_color
popup=f"Tree #{row.tree_number} ({row.species_latin})", popup=f"Tree #{tree_id}, {species} ({species_de}). From {times['min']} to {times['max']}\n{table}",
).add_to(interactive_map) ).add_to(interactive_map)
output_map = OUTPUT_DIR / INPUT_FILE.with_suffix('.html').name output_map = OUTPUT_DIR / INPUT_FILE.with_suffix('.html').name
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment