Skip to content

Commit

Permalink
Specifying raster file to zonal_stats in setup_basic_stress_data() le…
Browse files Browse the repository at this point in the history
…ad to proj issues. Bypassed when source raster is loaded with rasterio and affine transform specified
  • Loading branch information
apryet authored and aleaf committed Sep 23, 2024
1 parent c66aab9 commit a57b3a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mfsetup/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ def setup_basic_stress_data(model, shapefile=None, csvfile=None,
if meta['transform'][0] > m.modelgrid.delr[0]:
all_touched = True
stat = entry['stat']
results = zonal_stats(polygons, filename, stats=stat,
# load raster and specify affine transform to avoid issues with proj
with rasterio.open(filename) as src:
affine = src.transform
array = src.read(1)
results = zonal_stats(polygons, array, affine=affine, stats=stat,
all_touched=all_touched)
#values = np.ones((m.nrow * m.ncol), dtype=float) * np.nan
#values[cells_with_bc] = np.array([r[stat] for r in results])
Expand Down

0 comments on commit a57b3a6

Please sign in to comment.