Spaces:
Sleeping
Sleeping
Updated upload data app map center
Browse files- apps/upload.py +13 -4
apps/upload.py
CHANGED
@@ -63,9 +63,15 @@ def app():
|
|
63 |
# st.write(f"Saved to {file_path}")
|
64 |
|
65 |
with row1_col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
if backend == "pydeck":
|
67 |
|
68 |
-
gdf = gpd.read_file(file_path)
|
69 |
column_names = gdf.columns.values.tolist()
|
70 |
random_column = None
|
71 |
with container:
|
@@ -75,13 +81,16 @@ def app():
|
|
75 |
"Select a column to apply random colors", column_names
|
76 |
)
|
77 |
|
78 |
-
m = leafmap.Map()
|
79 |
m.add_gdf(gdf, random_color_column=random_column)
|
80 |
st.pydeck_chart(m)
|
81 |
|
82 |
else:
|
83 |
-
m = leafmap.Map(draw_export=True)
|
84 |
-
m.
|
|
|
|
|
|
|
85 |
m.to_streamlit(width=width, height=height)
|
86 |
|
87 |
else:
|
|
|
63 |
# st.write(f"Saved to {file_path}")
|
64 |
|
65 |
with row1_col1:
|
66 |
+
if file_path.lower().endswith(".kml"):
|
67 |
+
gpd.io.file.fiona.drvsupport.supported_drivers["KML"] = "rw"
|
68 |
+
gdf = gpd.read_file(file_path, driver="KML")
|
69 |
+
else:
|
70 |
+
gdf = gpd.read_file(file_path)
|
71 |
+
lon = gdf.centroid.iloc[0].x
|
72 |
+
lat = gdf.centroid.iloc[0].y
|
73 |
if backend == "pydeck":
|
74 |
|
|
|
75 |
column_names = gdf.columns.values.tolist()
|
76 |
random_column = None
|
77 |
with container:
|
|
|
81 |
"Select a column to apply random colors", column_names
|
82 |
)
|
83 |
|
84 |
+
m = leafmap.Map(center=(lat, lon))
|
85 |
m.add_gdf(gdf, random_color_column=random_column)
|
86 |
st.pydeck_chart(m)
|
87 |
|
88 |
else:
|
89 |
+
m = leafmap.Map(center=(lat, lon), draw_export=True)
|
90 |
+
m.add_gdf(gdf, layer_name=layer_name)
|
91 |
+
# m.add_vector(file_path, layer_name=layer_name)
|
92 |
+
if backend == "folium":
|
93 |
+
m.zoom_to_gdf(gdf)
|
94 |
m.to_streamlit(width=width, height=height)
|
95 |
|
96 |
else:
|