wanwanlin0521 commited on
Commit
9aa237f
·
verified ·
1 Parent(s): 28d292d

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -2
src/streamlit_app.py CHANGED
@@ -254,8 +254,15 @@ crime_dropdown = ipywidgets.Dropdown(
254
  options= sorted(top_10_crimes),
255
  description="Crime Type:")
256
 
257
- # Load geojson file.
258
- # gdf_counties = gpd.read_file("County_Boundary.geojson")
 
 
 
 
 
 
 
259
 
260
  # Creat dropdown menu.
261
  year_dropdown = ipywidgets.Dropdown(
 
254
  options= sorted(top_10_crimes),
255
  description="Crime Type:")
256
 
257
+ # Define the path to the GeoJSON file (relative to the script's location)
258
+ GEOJSON_PATH = Path(__file__).parent / "County_Boundary.geojson"
259
+
260
+ # Load the GeoJSON file with error handling
261
+ try:
262
+ gdf_counties = gpd.read_file(GEOJSON_PATH)
263
+ except FileNotFoundError:
264
+ st.error("Error: 'County_Boundary.geojson' file not found in the /app/src/ directory. Please ensure the file is included in the project.")
265
+ st.stop()
266
 
267
  # Creat dropdown menu.
268
  year_dropdown = ipywidgets.Dropdown(