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: ...@@ -38,27 +38,37 @@ 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]
folium.Circle( table = grouped_df.drop(coordinates, axis=1).describe().to_html()
location=[row.latitude, row.longitude], tree_id = tree['tree_number']
tooltip=row.species_latin, lat = tree['latitude']
radius=50, # [m] lon = tree['longitude']
color="black", species = tree['species_latin']
weight=1, species_de = tree['species_german']
fill_opacity=0.9, soil = tree['soil_composition']
opacity=1, times = grouped_df['timestamp'].agg(['min', 'max'])
fill_color="green", folium.Circle(
fill=False, # gets overridden by fill_color location=[lat, lon],
popup=f"Tree #{row.tree_number} ({row.species_latin})", tooltip=f"{species} ({species_de})",
).add_to(interactive_map) 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 output_map = OUTPUT_DIR / INPUT_FILE.with_suffix('.html').name
interactive_map.save(output_map) 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