Skip to content

Commit 9687d28

Browse files
committed
Do not drop annotated catchments.
1 parent 20eeb88 commit 9687d28

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

match_catchments_and_lsoas.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,13 @@ catchments = gpd.read_file(ROOT / 'catchments_consolidated.shp').set_index('iden
3030
print(f'loaded {len(catchments)} catchments')
3131
catchments.head()
3232

33-
# Drop catchments that are annotated with an overlap comment.
34-
catchments = catchments[~catchments.comment.str.startswith("Overlap").fillna(False)]
35-
print(f'retained {len(catchments)} after dropping annotated catchments')
36-
3733
# Drop all scottish water catchments because there should not be overlap with LSOAs.
3834
catchments = catchments[catchments.company != "scottish_water"]
3935
print(f'retained {len(catchments)} after dropping Scottish Water')
4036
```
4137

4238
```python
43-
# Find non-trivial intersections between treatment works. That have not already been
39+
# Find non-trivial intersections between treatment works. That have not already been
4440
# annotated.
4541
sindex = catchments.geometry.sindex
4642
indices = sindex.query_bulk(catchments.geometry).T
@@ -71,7 +67,7 @@ identifiers = catchments.index.values[indices]
7167
graph = nx.Graph()
7268
graph.add_edges_from([(*edge, {"weight": area}) for edge, area in zip(identifiers, intersection_areas)])
7369
components = list(sorted(
74-
nx.connected_components(graph),
70+
nx.connected_components(graph),
7571
key=lambda nodes: sum(data["weight"] for *_, data in graph.edges(nodes, data=True)),
7672
reverse=True,
7773
))
@@ -117,7 +113,7 @@ grouped = intersections.groupby("LSOA11CD")
117113
frac_covered = grouped.intersection_area.sum() / lsoas.geometry.area
118114

119115
coverage = pd.DataFrame({
120-
"n_catchments": grouped.identifier.nunique(),
116+
"n_catchments": grouped.identifier.nunique(),
121117
"frac": frac_covered,
122118
})
123119

@@ -152,11 +148,11 @@ for lsoa_code, subset in tqdm(intersections.groupby('LSOA11CD')):
152148
else:
153149
identifier = subset.identifier.iloc[0]
154150
all_intersecting = catchments.geometry.loc[identifier]
155-
# Evaluate the intersection of the LSOA with any catchment by intersecting with the spatial
151+
# Evaluate the intersection of the LSOA with any catchment by intersecting with the spatial
156152
# union of the catchments.
157153
intersection = all_intersecting.intersection(lsoas.geometry.loc[lsoa_code])
158154
coverage[lsoa_code] = intersection.area
159-
155+
160156
coverage = pd.Series(coverage)
161157

162158
# Compute the coverage and fill with zeros where there are no intersections.

0 commit comments

Comments
 (0)