Update app.py
Browse files
app.py
CHANGED
@@ -153,7 +153,7 @@ def interpolation_geojson(json_file, chem_symbol, lat_min, lat_max, long_min, lo
|
|
153 |
data_variance = np.var(values)
|
154 |
data_min = np.min(values)
|
155 |
data_max = np.max(values)
|
156 |
-
data_count = len(
|
157 |
|
158 |
# Prepare message with statistics
|
159 |
message = f"Heatmap of {interpolation_type} interpolated data created successfully for {chem_symbol}.\n"
|
@@ -623,7 +623,7 @@ def interpolation_contour(json_file, chem_symbol, lat_min, lat_max, long_min, lo
|
|
623 |
data_variance = np.var(values)
|
624 |
data_min = np.min(values)
|
625 |
data_max = np.max(values)
|
626 |
-
data_count = len(
|
627 |
|
628 |
# Prepare message with statistics
|
629 |
message = f"Contour map of {interpolation_type} interpolated data created successfully for {chem_symbol}.\n"
|
@@ -1141,12 +1141,11 @@ def plot_high_value_points(geojson_file, chem_symbol, lat_min, lat_max, long_min
|
|
1141 |
# Calculate statistics of the chemical values
|
1142 |
chem_values = gdf[chem_symbol].values
|
1143 |
mean_value = np.mean(chem_values)
|
1144 |
-
mode_value = stats.mode(chem_values)
|
1145 |
median_value = np.median(chem_values)
|
1146 |
std_deviation = np.std(chem_values)
|
1147 |
variance = np.var(chem_values)
|
1148 |
data_count = len(chem_values)
|
1149 |
-
|
1150 |
# Filter points with values higher than the threshold
|
1151 |
high_value_points = gdf[gdf[chem_symbol] > threshold]
|
1152 |
|
@@ -1157,20 +1156,34 @@ def plot_high_value_points(geojson_file, chem_symbol, lat_min, lat_max, long_min
|
|
1157 |
|
1158 |
# Add markers for high value points with tooltips
|
1159 |
for idx, row in high_value_points.iterrows():
|
|
|
|
|
1160 |
folium.Marker(
|
1161 |
location=[row.geometry.y, row.geometry.x],
|
1162 |
-
tooltip=
|
1163 |
).add_to(m)
|
1164 |
|
1165 |
# Add layer control to toggle markers
|
1166 |
folium.LayerControl().add_to(m)
|
1167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1168 |
|
1169 |
north_arrow_svg = """
|
1170 |
<div style="position: fixed;
|
1171 |
-
|
1172 |
z-index: 1000; pointer-events: none;">
|
1173 |
-
<div>North</div>
|
1174 |
<svg version="1.1" id="icons" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 128 128" style="enable-background:new 0 0 128 128" xml:space="preserve">
|
1175 |
<style>.st0,.st1{display:none;fill:#191919}.st1,.st3{fill-rule:evenodd;clip-rule:evenodd}.st3,.st4{display:inline;fill:#191919}</style>
|
1176 |
<g id="row1">
|
@@ -1189,9 +1202,8 @@ def plot_high_value_points(geojson_file, chem_symbol, lat_min, lat_max, long_min
|
|
1189 |
message += f"Mode: {mode_value} ppm\n"
|
1190 |
message += f"Median: {median_value:.2f} ppm\n"
|
1191 |
message += f"Standard Deviation: {std_deviation:.2f} ppm\n"
|
1192 |
-
message += f"Variance: {variance:.2f} ppm"
|
1193 |
-
message += f"Number of points: {data_count}"
|
1194 |
-
|
1195 |
return {
|
1196 |
"message": message,
|
1197 |
"html": html_content
|
@@ -1199,7 +1211,6 @@ def plot_high_value_points(geojson_file, chem_symbol, lat_min, lat_max, long_min
|
|
1199 |
|
1200 |
except Exception as e:
|
1201 |
return {"message": f"An error occurred: {str(e)}"}
|
1202 |
-
|
1203 |
|
1204 |
|
1205 |
def Manager_agent(query, lat_min, lat_max, long_min, long_max):
|
|
|
153 |
data_variance = np.var(values)
|
154 |
data_min = np.min(values)
|
155 |
data_max = np.max(values)
|
156 |
+
data_count = len(values)
|
157 |
|
158 |
# Prepare message with statistics
|
159 |
message = f"Heatmap of {interpolation_type} interpolated data created successfully for {chem_symbol}.\n"
|
|
|
623 |
data_variance = np.var(values)
|
624 |
data_min = np.min(values)
|
625 |
data_max = np.max(values)
|
626 |
+
data_count = len(values)
|
627 |
|
628 |
# Prepare message with statistics
|
629 |
message = f"Contour map of {interpolation_type} interpolated data created successfully for {chem_symbol}.\n"
|
|
|
1141 |
# Calculate statistics of the chemical values
|
1142 |
chem_values = gdf[chem_symbol].values
|
1143 |
mean_value = np.mean(chem_values)
|
1144 |
+
mode_value = stats.mode(chem_values)
|
1145 |
median_value = np.median(chem_values)
|
1146 |
std_deviation = np.std(chem_values)
|
1147 |
variance = np.var(chem_values)
|
1148 |
data_count = len(chem_values)
|
|
|
1149 |
# Filter points with values higher than the threshold
|
1150 |
high_value_points = gdf[gdf[chem_symbol] > threshold]
|
1151 |
|
|
|
1156 |
|
1157 |
# Add markers for high value points with tooltips
|
1158 |
for idx, row in high_value_points.iterrows():
|
1159 |
+
tooltip_text = (f'{chem_symbol}: {row[chem_symbol]:.2f} ppm<br>'
|
1160 |
+
f'Coordinates: ({row.geometry.y:.6f}, {row.geometry.x:.6f})')
|
1161 |
folium.Marker(
|
1162 |
location=[row.geometry.y, row.geometry.x],
|
1163 |
+
tooltip=tooltip_text
|
1164 |
).add_to(m)
|
1165 |
|
1166 |
# Add layer control to toggle markers
|
1167 |
folium.LayerControl().add_to(m)
|
1168 |
+
# Add Measure Control with custom CSS to position it lower
|
1169 |
+
measure_control = MeasureControl()
|
1170 |
+
m.add_child(measure_control)
|
1171 |
+
|
1172 |
+
measure_control_css = """
|
1173 |
+
<style>
|
1174 |
+
.leaflet-control-measure {
|
1175 |
+
top: 60px !important; /* Adjust this value to move the control lower */
|
1176 |
+
}
|
1177 |
+
</style>
|
1178 |
+
"""
|
1179 |
+
m.get_root().html.add_child(folium.Element(measure_control_css))
|
1180 |
+
|
1181 |
|
1182 |
north_arrow_svg = """
|
1183 |
<div style="position: fixed;
|
1184 |
+
top: 40px; right: 10px; width: 40px; height: 40px;
|
1185 |
z-index: 1000; pointer-events: none;">
|
1186 |
+
<div style="margin-top:22px;">North</div>
|
1187 |
<svg version="1.1" id="icons" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 128 128" style="enable-background:new 0 0 128 128" xml:space="preserve">
|
1188 |
<style>.st0,.st1{display:none;fill:#191919}.st1,.st3{fill-rule:evenodd;clip-rule:evenodd}.st3,.st4{display:inline;fill:#191919}</style>
|
1189 |
<g id="row1">
|
|
|
1202 |
message += f"Mode: {mode_value} ppm\n"
|
1203 |
message += f"Median: {median_value:.2f} ppm\n"
|
1204 |
message += f"Standard Deviation: {std_deviation:.2f} ppm\n"
|
1205 |
+
message += f"Variance: {variance:.2f} ppm\n"
|
1206 |
+
message += f"Number of points: {data_count}\n"
|
|
|
1207 |
return {
|
1208 |
"message": message,
|
1209 |
"html": html_content
|
|
|
1211 |
|
1212 |
except Exception as e:
|
1213 |
return {"message": f"An error occurred: {str(e)}"}
|
|
|
1214 |
|
1215 |
|
1216 |
def Manager_agent(query, lat_min, lat_max, long_min, long_max):
|