-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_ui.py
34 lines (24 loc) · 986 Bytes
/
export_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import geemap
import ee
import ipywidgets as widgets
from IPython.display import display, clear_output, FileLink
class ExportUI:
def __init__(self, dataframe):
self.dataframe = dataframe
self.final_df = dataframe
# Create a button for downloading the data and style it
self.download_button = widgets.Button(description="Download Data",\
button_style='info')
self.download_button.on_click(self.on_download_button_clicked)
# Output widget to display information
self.output = widgets.Output()
def on_download_button_clicked(self, b):
with self.output:
clear_output(wait=True)
# Convert final_df to .csv
if not self.final_df.empty:
self.final_df.to_csv('output_data.csv', index=True)
else:
print("No data available to download!")
def display(self):
display( widgets.HBox([self.download_button, self.output]))