Spaces:
Sleeping
Sleeping
Add grid point table to bottom of page
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import zipfile
|
3 |
import gradio as gr
|
|
|
4 |
import plotly.graph_objects as go
|
5 |
|
6 |
from geo_tools import (
|
@@ -39,12 +40,17 @@ def gr_generate_map(
|
|
39 |
for file in file_list:
|
40 |
fp.write(file, compress_type=zipfile.ZIP_DEFLATED)
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
else:
|
47 |
indices, labels = get_cached_grid_indices(grid_path)
|
|
|
48 |
box = go.Scattermapbox(
|
49 |
lat=indices[:, 1],
|
50 |
lon=indices[:, 0],
|
@@ -155,7 +161,7 @@ def gr_generate_map(
|
|
155 |
modebar_remove=modebar_icons,
|
156 |
)
|
157 |
|
158 |
-
return fig, prefix + ".zip", prefix + ".csv"
|
159 |
|
160 |
|
161 |
with gr.Blocks() as demo:
|
@@ -188,12 +194,14 @@ with gr.Blocks() as demo:
|
|
188 |
],
|
189 |
)
|
190 |
grid_shapefile = gr.File(label="Grid Shapefile")
|
191 |
-
grid_point_info = gr.File(label="
|
|
|
|
|
192 |
|
193 |
grid_button.click(
|
194 |
gr_generate_map,
|
195 |
inputs=[grid_token, grid_side_len, grid_show_mask],
|
196 |
-
outputs=[grid_map, grid_shapefile, grid_point_info],
|
197 |
)
|
198 |
|
199 |
grid_region.change(
|
@@ -206,7 +214,7 @@ with gr.Blocks() as demo:
|
|
206 |
grid_show_police,
|
207 |
grid_region,
|
208 |
],
|
209 |
-
outputs=[grid_map, grid_shapefile, grid_point_info],
|
210 |
)
|
211 |
|
212 |
demo.queue(concurrency_count=10).launch(debug=True)
|
|
|
1 |
import os
|
2 |
import zipfile
|
3 |
import gradio as gr
|
4 |
+
import pandas as pd
|
5 |
import plotly.graph_objects as go
|
6 |
|
7 |
from geo_tools import (
|
|
|
40 |
for file in file_list:
|
41 |
fp.write(file, compress_type=zipfile.ZIP_DEFLATED)
|
42 |
|
43 |
+
grid_point_df = pd.DataFrame(
|
44 |
+
data=[
|
45 |
+
[labels[i], f"{indices[i][1]}, {indices[i][0]}"]
|
46 |
+
for i in range(len(indices))
|
47 |
+
],
|
48 |
+
columns=["Name", "Coordinates"],
|
49 |
+
)
|
50 |
+
grid_point_df.to_csv(prefix + ".csv", index=False)
|
51 |
else:
|
52 |
indices, labels = get_cached_grid_indices(grid_path)
|
53 |
+
grid_point_df = pd.read_csv(prefix + ".csv")
|
54 |
box = go.Scattermapbox(
|
55 |
lat=indices[:, 1],
|
56 |
lon=indices[:, 0],
|
|
|
161 |
modebar_remove=modebar_icons,
|
162 |
)
|
163 |
|
164 |
+
return fig, prefix + ".zip", prefix + ".csv", grid_point_df
|
165 |
|
166 |
|
167 |
with gr.Blocks() as demo:
|
|
|
194 |
],
|
195 |
)
|
196 |
grid_shapefile = gr.File(label="Grid Shapefile")
|
197 |
+
grid_point_info = gr.File(label="Grid Point Info")
|
198 |
+
|
199 |
+
grid_point_table = gr.Dataframe(label="Grid Point Info Table")
|
200 |
|
201 |
grid_button.click(
|
202 |
gr_generate_map,
|
203 |
inputs=[grid_token, grid_side_len, grid_show_mask],
|
204 |
+
outputs=[grid_map, grid_shapefile, grid_point_info, grid_point_table],
|
205 |
)
|
206 |
|
207 |
grid_region.change(
|
|
|
214 |
grid_show_police,
|
215 |
grid_region,
|
216 |
],
|
217 |
+
outputs=[grid_map, grid_shapefile, grid_point_info, grid_point_table],
|
218 |
)
|
219 |
|
220 |
demo.queue(concurrency_count=10).launch(debug=True)
|