Skip to content

Commit

Permalink
Update metric_utilities.py
Browse files Browse the repository at this point in the history
use comprehension
  • Loading branch information
barneydobson committed Mar 19, 2024
1 parent f1d89af commit 2afaa3a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions swmmanywhere/metric_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,13 @@ def create_grid(bbox: tuple,
dy = scale
minx, miny, maxx, maxy = bbox

grid = []
for i in range(int((maxx - minx) // dx + 1)):
for j in range(int((maxy - miny) // dy + 1)):
grid.append({'geometry' : shapely.Polygon([(minx + i * dx,
miny + j * dy),
(minx + (i + 1) * dx, miny + j * dy),
(minx + (i + 1) * dx, miny + (j + 1) * dy),
(minx + i * dx, miny + (j + 1) * dy)]),
'sub_id' : f'{i}_{j}'})
grid = [{'geometry': shapely.geometry.Polygon([(minx + i * dx, miny + j * dy),
(minx + (i + 1) * dx, miny + j * dy),
(minx + (i + 1) * dx, miny + (j + 1) * dy),
(minx + i * dx, miny + (j + 1) * dy)]),
'sub_id': f'{i}_{j}'}
for i in range(int((maxx - minx) // dx + 1))
for j in range(int((maxy - miny) // dy + 1))]
return gpd.GeoDataFrame(grid)

@metrics.register
Expand Down

0 comments on commit 2afaa3a

Please sign in to comment.