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

Trees open data : More information in table.

parent 3a54eeb7
......@@ -38,27 +38,37 @@ else:
df = pd.read_parquet(INPUT_FILE, engine='fastparquet')
interactive_map = folium.Map()
species = 'species_latin'
coordinates = ['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
interactive_map = folium.Map()
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 row in grouped_df.itertuples():
folium.Circle(
location=[row.latitude, row.longitude],
tooltip=row.species_latin,
radius=50, # [m]
color="black",
weight=1,
fill_opacity=0.9,
opacity=1,
fill_color="green",
fill=False, # gets overridden by fill_color
popup=f"Tree #{row.tree_number} ({row.species_latin})",
).add_to(interactive_map)
for same, grouped_df in df.groupby('tree_number'):
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(
location=[lat, lon],
tooltip=f"{species} ({species_de})",
radius=50, # [m]
color="black",
weight=1,
fill_opacity=0.9,
opacity=1,
fill_color="green",
fill=False, # gets overridden by fill_color
popup=f"Tree #{tree_id}, {species} ({species_de}). From {times['min']} to {times['max']}\n{table}",
).add_to(interactive_map)
output_map = OUTPUT_DIR / INPUT_FILE.with_suffix('.html').name
interactive_map.save(output_map)
......
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