Connor Sutton
commited on
Commit
·
c7a4712
1
Parent(s):
99e2054
resolved issues with KMZ/KML uploads
Browse files
geospatial-data-converter/app.py
CHANGED
@@ -63,11 +63,13 @@ if st.session_state.arcgis_url:
|
|
63 |
st.session_state.gdf = gdf
|
64 |
|
65 |
elif st.session_state.uploaded_file is not None:
|
|
|
66 |
st.session_state.fn_without_extension, _ = os.path.splitext(
|
67 |
os.path.basename(st.session_state.uploaded_file.name),
|
68 |
)
|
69 |
-
|
70 |
st.session_state.gdf = read_file(st.session_state.uploaded_file)
|
|
|
|
|
71 |
|
72 |
if st.session_state.gdf is not None:
|
73 |
st.selectbox(
|
@@ -103,6 +105,8 @@ if st.session_state.gdf is not None:
|
|
103 |
"*(geometry omitted for display purposes)*",
|
104 |
)
|
105 |
|
106 |
-
display_df = st.session_state.gdf.drop(columns=["geometry"])
|
|
|
|
|
107 |
|
108 |
st.dataframe(display_df)
|
|
|
63 |
st.session_state.gdf = gdf
|
64 |
|
65 |
elif st.session_state.uploaded_file is not None:
|
66 |
+
# try:
|
67 |
st.session_state.fn_without_extension, _ = os.path.splitext(
|
68 |
os.path.basename(st.session_state.uploaded_file.name),
|
69 |
)
|
|
|
70 |
st.session_state.gdf = read_file(st.session_state.uploaded_file)
|
71 |
+
# except AttributeError:
|
72 |
+
# pass # there is a lingering file from the previous instance, but it can be ignored
|
73 |
|
74 |
if st.session_state.gdf is not None:
|
75 |
st.selectbox(
|
|
|
105 |
"*(geometry omitted for display purposes)*",
|
106 |
)
|
107 |
|
108 |
+
display_df = st.session_state.gdf.drop(columns=["geometry"]).to_dict(
|
109 |
+
orient="records",
|
110 |
+
)
|
111 |
|
112 |
st.dataframe(display_df)
|
geospatial-data-converter/kml_tricks.py
CHANGED
@@ -89,7 +89,9 @@ def extract_data_from_kml_code(kml_code: str) -> pd.DataFrame:
|
|
89 |
# Create a generator that yields a dictionary for each row, containing the Placemark name and each SimpleData field
|
90 |
row_dicts = (
|
91 |
{
|
92 |
-
"Placemark_name": tag.parent.parent.find("name").text
|
|
|
|
|
93 |
**{field.get("name"): field.text for field in tag.find_all("simpledata")},
|
94 |
}
|
95 |
for tag in schema_data_tags
|
|
|
89 |
# Create a generator that yields a dictionary for each row, containing the Placemark name and each SimpleData field
|
90 |
row_dicts = (
|
91 |
{
|
92 |
+
"Placemark_name": tag.parent.parent.find("name").text
|
93 |
+
if tag.parent.parent.find("name")
|
94 |
+
else "[no name]",
|
95 |
**{field.get("name"): field.text for field in tag.find_all("simpledata")},
|
96 |
}
|
97 |
for tag in schema_data_tags
|