Spaces:
Runtime error
Runtime error
Update pag/monitor.py
Browse files- pag/monitor.py +31 -25
pag/monitor.py
CHANGED
|
@@ -83,18 +83,6 @@ def get_cuarted_df_for_field(df, field, date, metric, clientName):
|
|
| 83 |
return curated_df
|
| 84 |
|
| 85 |
|
| 86 |
-
def get_cuarted_df_for_field(df, field, date, metric, clientName):
|
| 87 |
-
curated_date_path = utils.get_curated_location_img_path(clientName, metric, date, field)
|
| 88 |
-
if curated_date_path is not None:
|
| 89 |
-
curated_df = gpd.read_file(curated_date_path)
|
| 90 |
-
else:
|
| 91 |
-
process.Download_image_in_given_date(clientName, metric, df, field, date)
|
| 92 |
-
process.mask_downladed_image(clientName, metric, df, field, date)
|
| 93 |
-
process.convert_maske_image_to_geodataframe(clientName, metric, df, field, date, df.crs)
|
| 94 |
-
curated_date_path = utils.get_curated_location_img_path(clientName, metric, date, field)
|
| 95 |
-
curated_df = gpd.read_file(curated_date_path)
|
| 96 |
-
return curated_df
|
| 97 |
-
|
| 98 |
def track(metric, field_name, src_df, client_name):
|
| 99 |
|
| 100 |
dates = []
|
|
@@ -174,21 +162,39 @@ def track(metric, field_name, src_df, client_name):
|
|
| 174 |
cmap = 'RdYlGn'
|
| 175 |
|
| 176 |
# Create a map of the field data
|
| 177 |
-
field_data_map = field_data.explore(
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
|
| 185 |
# Add Google Satellite as a base map
|
| 186 |
-
google_map = utils.basemaps['Google Satellite']
|
| 187 |
-
google_map.add_to(field_data_map)
|
| 188 |
-
|
| 189 |
-
# Display the map
|
| 190 |
-
st_folium(field_data_map, width = 725, key=f'Field Data Map - {metric}')
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
#Dwonload Links
|
| 194 |
|
|
|
|
| 83 |
return curated_df
|
| 84 |
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
def track(metric, field_name, src_df, client_name):
|
| 87 |
|
| 88 |
dates = []
|
|
|
|
| 162 |
cmap = 'RdYlGn'
|
| 163 |
|
| 164 |
# Create a map of the field data
|
| 165 |
+
# field_data_map = field_data.explore(
|
| 166 |
+
# column=f'{metric}_{date}',
|
| 167 |
+
# cmap=cmap,
|
| 168 |
+
# legend=True,
|
| 169 |
+
# vmin=0,
|
| 170 |
+
# vmax=1,
|
| 171 |
+
# marker_type='circle', marker_kwds={'radius':5.3, 'fill':True})
|
| 172 |
|
| 173 |
# Add Google Satellite as a base map
|
| 174 |
+
# google_map = utils.basemaps['Google Satellite']
|
| 175 |
+
# google_map.add_to(field_data_map)
|
| 176 |
+
|
| 177 |
+
# # Display the map
|
| 178 |
+
# st_folium(field_data_map, width = 725, key=f'Field Data Map - {metric}')
|
| 179 |
+
df = field_data.copy()
|
| 180 |
+
df['latitude'] = df['geometry'].y
|
| 181 |
+
df['longitude'] = df['geometry'].x
|
| 182 |
+
|
| 183 |
+
# Create a scatter plot
|
| 184 |
+
fig = px.scatter_mapbox(
|
| 185 |
+
df,
|
| 186 |
+
lat='latitude',
|
| 187 |
+
lon='longitude',
|
| 188 |
+
color=f'{metric}_{date}',
|
| 189 |
+
color_continuous_scale='RdYlGn',
|
| 190 |
+
range_color=(0, 1),
|
| 191 |
+
size_max=15,
|
| 192 |
+
zoom=13,
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
# Add the base map
|
| 196 |
+
fig.update_layout(mapbox_style="open-street-map")
|
| 197 |
+
st.plotly_chart(fig)
|
| 198 |
|
| 199 |
#Dwonload Links
|
| 200 |
|