Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,6 +75,7 @@ def geocode(address):
|
|
| 75 |
lat, lon = location.latitude, location.longitude
|
| 76 |
return lat, lon
|
| 77 |
|
|
|
|
| 78 |
def extract_vertices_1(multipolygon):
|
| 79 |
vertices = []
|
| 80 |
for polygon in multipolygon.geoms: # Access the individual polygons
|
|
@@ -84,7 +85,7 @@ def extract_vertices_1(multipolygon):
|
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
-
def
|
| 88 |
all_data = []
|
| 89 |
for idx, geom in enumerate(gdf.geometry):
|
| 90 |
if geom.geom_type == 'MultiPolygon':
|
|
@@ -95,7 +96,7 @@ def extract_vertices(gdf):
|
|
| 95 |
|
| 96 |
df = pd.DataFrame(vertices, columns=['Lon', 'Lat'])
|
| 97 |
df['index_gdf'] = idx # Add index from GeoDataFrame
|
| 98 |
-
all_data.append(df)
|
| 99 |
|
| 100 |
return pd.concat(all_data).query('Lat==Lat').reset_index(drop=1).drop(columns='index_gdf')
|
| 101 |
|
|
@@ -155,7 +156,7 @@ m = map_perimeters(gdf_cut, address)
|
|
| 155 |
indicents = list(gdf_cut['Incident'].values)
|
| 156 |
incident_edge = st.sidebar.selectbox(
|
| 157 |
'Find Distance to Closest Edge:', indicents)
|
| 158 |
-
vertices =
|
| 159 |
vertices["Lat_address"] = lat
|
| 160 |
vertices["Lon_address"] = lon
|
| 161 |
vertices['Distance'] = [
|
|
|
|
| 75 |
lat, lon = location.latitude, location.longitude
|
| 76 |
return lat, lon
|
| 77 |
|
| 78 |
+
|
| 79 |
def extract_vertices_1(multipolygon):
|
| 80 |
vertices = []
|
| 81 |
for polygon in multipolygon.geoms: # Access the individual polygons
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
+
def extract_vertices_final(gdf):
|
| 89 |
all_data = []
|
| 90 |
for idx, geom in enumerate(gdf.geometry):
|
| 91 |
if geom.geom_type == 'MultiPolygon':
|
|
|
|
| 96 |
|
| 97 |
df = pd.DataFrame(vertices, columns=['Lon', 'Lat'])
|
| 98 |
df['index_gdf'] = idx # Add index from GeoDataFrame
|
| 99 |
+
all_data.append(df[['Lat','Lon','index_gdf']])
|
| 100 |
|
| 101 |
return pd.concat(all_data).query('Lat==Lat').reset_index(drop=1).drop(columns='index_gdf')
|
| 102 |
|
|
|
|
| 156 |
indicents = list(gdf_cut['Incident'].values)
|
| 157 |
incident_edge = st.sidebar.selectbox(
|
| 158 |
'Find Distance to Closest Edge:', indicents)
|
| 159 |
+
vertices = extract_vertices_final(gdf_cut[gdf_cut['Incident']==incident_edge])
|
| 160 |
vertices["Lat_address"] = lat
|
| 161 |
vertices["Lon_address"] = lon
|
| 162 |
vertices['Distance'] = [
|