Spaces:
Sleeping
Sleeping
Updated gdf centroid
Browse files- apps/vector.py +2 -5
apps/vector.py
CHANGED
@@ -13,8 +13,7 @@ def save_uploaded_file(file_content, file_name):
|
|
13 |
|
14 |
_, file_extension = os.path.splitext(file_name)
|
15 |
file_id = str(uuid.uuid4())
|
16 |
-
file_path = os.path.join(tempfile.gettempdir(),
|
17 |
-
f"{file_id}{file_extension}")
|
18 |
|
19 |
with open(file_path, "wb") as file:
|
20 |
file.write(file_content.getbuffer())
|
@@ -61,7 +60,6 @@ def app():
|
|
61 |
elif url:
|
62 |
file_path = url
|
63 |
layer_name = url.split("/")[-1].split(".")[0]
|
64 |
-
# st.write(f"Saved to {file_path}")
|
65 |
|
66 |
with row1_col1:
|
67 |
if file_path.lower().endswith(".kml"):
|
@@ -69,8 +67,7 @@ def app():
|
|
69 |
gdf = gpd.read_file(file_path, driver="KML")
|
70 |
else:
|
71 |
gdf = gpd.read_file(file_path)
|
72 |
-
lon = gdf
|
73 |
-
lat = gdf.centroid.iloc[0].y
|
74 |
if backend == "pydeck":
|
75 |
|
76 |
column_names = gdf.columns.values.tolist()
|
|
|
13 |
|
14 |
_, file_extension = os.path.splitext(file_name)
|
15 |
file_id = str(uuid.uuid4())
|
16 |
+
file_path = os.path.join(tempfile.gettempdir(), f"{file_id}{file_extension}")
|
|
|
17 |
|
18 |
with open(file_path, "wb") as file:
|
19 |
file.write(file_content.getbuffer())
|
|
|
60 |
elif url:
|
61 |
file_path = url
|
62 |
layer_name = url.split("/")[-1].split(".")[0]
|
|
|
63 |
|
64 |
with row1_col1:
|
65 |
if file_path.lower().endswith(".kml"):
|
|
|
67 |
gdf = gpd.read_file(file_path, driver="KML")
|
68 |
else:
|
69 |
gdf = gpd.read_file(file_path)
|
70 |
+
lon, lat = leafmap.gdf_centroid(gdf)
|
|
|
71 |
if backend == "pydeck":
|
72 |
|
73 |
column_names = gdf.columns.values.tolist()
|