Fer-geo commited on
Commit
6a53486
·
1 Parent(s): 46aef50

fix downl button

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -5,10 +5,11 @@ import pandas as pd
5
  import geopandas as gpd
6
  from difflib import get_close_matches
7
  import tempfile
 
8
 
9
 
10
- from io import BytesIO
11
 
 
12
 
13
 
14
  def convert_to_gdf(uploaded_file):
@@ -27,7 +28,9 @@ def convert_to_gdf(uploaded_file):
27
 
28
  # add logo D:\Terradot\repos\crea-carbon-model\app\logo.jpg
29
 
30
- st.sidebar.image('logo.jpg', width=200)
 
 
31
  st.sidebar.title('Proyecto Crea')
32
  st.sidebar.write('Solo uso interno')
33
  # add sidebar with 2 upload buttons
@@ -35,6 +38,7 @@ st.sidebar.header('Upload Files')
35
  uploaded_file = st.sidebar.file_uploader('Upload your shapefile', type=['shp', 'geojson', 'json'], disabled = True)
36
  uploaded_file2 = st.sidebar.file_uploader('Upload your csv file', type=['csv'], disabled = True)
37
 
 
38
  if uploaded_file is not None:
39
  lotes_gdf = convert_to_gdf(uploaded_file)
40
  st.write(lotes_gdf)
@@ -100,7 +104,7 @@ if test:
100
 
101
 
102
  with col2:
103
- st.header('Campo')
104
  selected_company = st.session_state['selected_company']
105
  obs_df_comp = obs_df[obs_df['EMPRESA'] == selected_company]
106
 
@@ -172,7 +176,7 @@ if test:
172
  with col3:
173
  if st.session_state['show_field']:
174
 
175
- st.header('Lote')
176
  gdf = st.session_state['lote_gdf']
177
  selected_company = st.session_state['selected_company']
178
  farm_gdf = gdf[gdf['empresa'] == selected_company]
@@ -251,10 +255,16 @@ if test:
251
 
252
 
253
  ##### Download Section #####
 
 
 
 
 
 
254
  st.sidebar.download_button(
255
  label="Download GeoJSON",
256
  data=gdf.to_json().encode('utf-8'),
257
- file_name=f'{selected_company}.geojson',
258
  # mime='text/csv',
259
  mime = 'application/json',
260
  )
 
5
  import geopandas as gpd
6
  from difflib import get_close_matches
7
  import tempfile
8
+ import datetime
9
 
10
 
 
11
 
12
+ from io import BytesIO
13
 
14
 
15
  def convert_to_gdf(uploaded_file):
 
28
 
29
  # add logo D:\Terradot\repos\crea-carbon-model\app\logo.jpg
30
 
31
+ st.sidebar.image('logo.jpg', width=300)
32
+ st.sidebar.markdown("""<a href="https://terradot.earth/" target="_blank">Terradot</a>""", unsafe_allow_html=True)
33
+
34
  st.sidebar.title('Proyecto Crea')
35
  st.sidebar.write('Solo uso interno')
36
  # add sidebar with 2 upload buttons
 
38
  uploaded_file = st.sidebar.file_uploader('Upload your shapefile', type=['shp', 'geojson', 'json'], disabled = True)
39
  uploaded_file2 = st.sidebar.file_uploader('Upload your csv file', type=['csv'], disabled = True)
40
 
41
+
42
  if uploaded_file is not None:
43
  lotes_gdf = convert_to_gdf(uploaded_file)
44
  st.write(lotes_gdf)
 
104
 
105
 
106
  with col2:
107
+ st.header('CAMPO')
108
  selected_company = st.session_state['selected_company']
109
  obs_df_comp = obs_df[obs_df['EMPRESA'] == selected_company]
110
 
 
176
  with col3:
177
  if st.session_state['show_field']:
178
 
179
+ st.header('LOTE')
180
  gdf = st.session_state['lote_gdf']
181
  selected_company = st.session_state['selected_company']
182
  farm_gdf = gdf[gdf['empresa'] == selected_company]
 
255
 
256
 
257
  ##### Download Section #####
258
+ # get today and hour minute
259
+ today = datetime.date.today()
260
+ now = datetime.datetime.now()
261
+ hour = now.hour
262
+ minute = now.minute
263
+
264
  st.sidebar.download_button(
265
  label="Download GeoJSON",
266
  data=gdf.to_json().encode('utf-8'),
267
+ file_name=f'TODO_{today}_{hour}_{minute}.geojson',
268
  # mime='text/csv',
269
  mime = 'application/json',
270
  )