khushidhar1210 commited on
Commit
46c4e1f
·
verified ·
1 Parent(s): 4862d3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -122,7 +122,19 @@ if uploaded_file is not None:
122
  nc = gpd.read_file("N_FLD_HAZ_AR.shp")
123
  sussex = gpd.read_file("S_FLD_HAZ_AR.shp")
124
  dela = gpd.GeoDataFrame(pd.concat([kent, nc, sussex], ignore_index=True))
125
- dela = dela.set_crs(kent.crs, allow_override=True).to_crs(epsg=3857)
 
 
 
 
 
 
 
 
 
 
 
 
126
  dela['geometry'] = dela['geometry'].apply(lambda x: x.buffer(0) if not x.is_valid else x)
127
 
128
  # Process uploaded KML/KMZ
 
122
  nc = gpd.read_file("N_FLD_HAZ_AR.shp")
123
  sussex = gpd.read_file("S_FLD_HAZ_AR.shp")
124
  dela = gpd.GeoDataFrame(pd.concat([kent, nc, sussex], ignore_index=True))
125
+
126
+ # First, check if the shapefile already has a CRS
127
+ if dela.crs is None:
128
+ # Set the CRS for the shapefile if it doesn't have one
129
+ dela = dela.set_crs("EPSG:4326", allow_override=True)
130
+ else:
131
+ # If the shapefile already has a CRS, make sure it's in the same CRS
132
+ dela = dela.to_crs("EPSG:4326")
133
+
134
+ # Reproject to Web Mercator (EPSG:3857)
135
+ dela = dela.to_crs(epsg=3857)
136
+
137
+ # Ensure valid geometries
138
  dela['geometry'] = dela['geometry'].apply(lambda x: x.buffer(0) if not x.is_valid else x)
139
 
140
  # Process uploaded KML/KMZ