github-actions[bot] commited on
Commit
d808075
·
1 Parent(s): 4818237

Add all files with LFS support

Browse files
Files changed (2) hide show
  1. analysis.py +6 -0
  2. app.py +7 -2
analysis.py CHANGED
@@ -1036,10 +1036,16 @@ def plot_seasonal_salinity_for_bays(
1036
  basemap_provider=ctx.providers.USGS.USTopo, # type: ignore
1037
  alpha=0.5,
1038
  shapefile_path="data/SAB/SAB.shp",
 
1039
  ):
1040
  """
1041
  Create seasonal plots of mean salinity values by WBID for N, E, W, SAB, GL and Lake Powell.
1042
  """
 
 
 
 
 
1043
  fig = plot_seasonal_salinity(
1044
  salinity_data.query(
1045
  "WBID.isin(['1061A', '1061B', '1061C', '1061D', '1061E', '1061F', '1061G', '1061H', '1055A'])"
 
1036
  basemap_provider=ctx.providers.USGS.USTopo, # type: ignore
1037
  alpha=0.5,
1038
  shapefile_path="data/SAB/SAB.shp",
1039
+ wbids=None,
1040
  ):
1041
  """
1042
  Create seasonal plots of mean salinity values by WBID for N, E, W, SAB, GL and Lake Powell.
1043
  """
1044
+ if wbids is None:
1045
+ wbids = gpd.read_file(shapefile_path)
1046
+ if wbids.crs is None:
1047
+ wbids.set_crs(epsg=6439, inplace=True)
1048
+ wbids = wbids.to_crs(epsg=3857)
1049
  fig = plot_seasonal_salinity(
1050
  salinity_data.query(
1051
  "WBID.isin(['1061A', '1061B', '1061C', '1061D', '1061E', '1061F', '1061G', '1061H', '1055A'])"
app.py CHANGED
@@ -337,10 +337,13 @@ def generate_seasonal_plot(data, year, shapefile_path):
337
  # Assuming the input coordinates are in WGS84 (EPSG:4326)
338
  data.set_crs(epsg=4326, inplace=True)
339
 
340
- # Ensure shapefile has CRS set
341
  if wbids.crs is None:
342
  wbids.set_crs(epsg=6439, inplace=True)
343
 
 
 
 
344
  st.write("Debug Info:")
345
  st.write(
346
  {
@@ -357,7 +360,9 @@ def generate_seasonal_plot(data, year, shapefile_path):
357
  }
358
  )
359
 
360
- return plot_seasonal_salinity_for_bays(data, year, shapefile_path=shapefile_path)
 
 
361
 
362
 
363
  # if ENABLE_TIMING:
 
337
  # Assuming the input coordinates are in WGS84 (EPSG:4326)
338
  data.set_crs(epsg=4326, inplace=True)
339
 
340
+ # Ensure shapefile has CRS set and transform to Web Mercator
341
  if wbids.crs is None:
342
  wbids.set_crs(epsg=6439, inplace=True)
343
 
344
+ # Pre-transform to Web Mercator (EPSG:3857) here to avoid issues in plotting function
345
+ wbids = wbids.to_crs(epsg=3857)
346
+
347
  st.write("Debug Info:")
348
  st.write(
349
  {
 
360
  }
361
  )
362
 
363
+ return plot_seasonal_salinity_for_bays(
364
+ data, year, shapefile_path=shapefile_path, wbids=wbids
365
+ )
366
 
367
 
368
  # if ENABLE_TIMING: