Skip to content

Commit ea951dc

Browse files
committed
Updated the dataset based upon the latest release, improved the reproducibility of the script and tweaked the styling colours to assist differentiating between the different risk categories.
1 parent e35eddd commit ea951dc

7 files changed

Lines changed: 5640 additions & 4777 deletions

flood_risk/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
[<img src="thumbnail.png">](trafford_flood_risk_styled.geojson)
2-
</br>
3-
41
<table>
52
<tr>
63
<td>Dataset name</td>
74
<td>Risk of Flooding from Rivers and Sea</td>
85
</tr>
96
<tr>
107
<td>Dataset description</td>
11-
<td>The dataset shows the chance of flooding from rivers and/or the sea, based on 50m cells in Traffordf. Each cell is allocated to one of four flood risk categories, taking into account flood defences and their condition.
8+
<td>The dataset, taken from the national assessment of flood risk for England produced using local expertise, shows the chance of flooding from rivers and/or the sea, based on cells of 50m within Trafford. Each cell is allocated one of four flood risk categories, taking into account flood defences and their condition.
129
</td>
1310
</tr>
1411
<tr>
@@ -21,7 +18,7 @@
2118
</tr>
2219
<tr>
2320
<td>Publisher URL</td>
24-
<td><a href="https://data.gov.uk/dataset/risk-of-flooding-from-rivers-and-sea1"></a>https://data.gov.uk/dataset/risk-of-flooding-from-rivers-and-sea1</td>
21+
<td><a href="https://www.data.gov.uk/dataset/bad20199-6d39-4aad-8564-26a46778fd94/risk-of-flooding-from-rivers-and-sea">https://www.data.gov.uk/dataset/bad20199-6d39-4aad-8564-26a46778fd94/risk-of-flooding-from-rivers-and-sea</a></td>
2522
</tr>
2623
<tr>
2724
<td>Geography</td>
@@ -33,7 +30,7 @@
3330
</tr>
3431
<tr>
3532
<td>Temporal coverage</td>
36-
<td>April 2017</td>
33+
<td>2018-03-28 - 2019-12-18</td>
3734
</tr>
3835
<tr>
3936
<td>Update frequency</td>
@@ -45,7 +42,7 @@
4542
</tr>
4643
<tr>
4744
<td>Attribution</td>
48-
<td>© Environment Agency copyright and/or database right 2017. All rights reserved. Some features of this map are based on digital spatial data from the Centre for Ecology & Hydrology, © NERC (CEH)© Crown copyright and database rights 2017 Ordnance Survey 100024198.</td>
45+
<td>© Environment Agency copyright and/or database right 2023. All rights reserved.</td>
4946
</tr>
5047
<tr>
5148
<td>Format</td>
@@ -57,7 +54,7 @@
5754
</tr>
5855
<tr>
5956
<td>Last updated</td>
60-
<td>March 2018</td>
57+
<td>2024-02-09</td>
6158
</tr>
6259
<tr>
6360
<td>Notes</td>

flood_risk/Risk_of_Flooding_from_Rivers_and_Sea.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

flood_risk/pre-processing.R

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
## Risk of Flooding from Rivers and Sea ##
22

33
# Source: Environment Agency
4-
# Publisher URL: https://data.gov.uk/dataset/risk-of-flooding-from-rivers-and-sea1
4+
# Publisher URL: https://www.data.gov.uk/dataset/bad20199-6d39-4aad-8564-26a46778fd94/risk-of-flooding-from-rivers-and-sea
55
# Licence: Open Government Licence 3.0
6+
# Attribution: (C) Environment Agency Copyright and/or Database Rights 2023. All rights reserved.
7+
# Last Updated: 2024-02-09
8+
# NOTE 1: "This year we are pausing the updates to this dataset after December 2023. This is in advance of publishing the first outputs from our new National Flood Risk Assessment. These outputs will be published by the end of 2024 and will include a new version of this dataset."
9+
# NOTE 2: The initial dataset is downloaded from https://environment.data.gov.uk/explore/8d57464f-d465-11e4-8790-f0def148f590 by creating a bounding polygon around Trafford. This file is large ~14MB.
610

7-
# load libraries---------------------------
11+
# Load libraries ---------------------------
812
library(tidyverse) ; library(sf)
913

10-
# load data ---------------------------
11-
flood <- st_read("flood_risk_radius.geojson") # processed in QGIS beforehand
1214

13-
trafford <- st_read("https://github.com/traffordDataLab/spatial_data/raw/master/local_authority/2016/trafford_local_authority_full_resolution.geojson") %>%
14-
st_set_crs(4326) %>%
15-
select(-lat, -lon)
15+
# Set sf geometry calculation method ---------------------------
16+
# Refer to the following for further information: https://github.com/r-spatial/sf/issues/1771
17+
is_sf_using_s2 <- sf_use_s2() # Store whether sf is using S2 or R2 geometry calculations
18+
sf_use_s2(FALSE) # Set sf to use R2 calculations as we get errors using S2
19+
20+
21+
# Load raw data and Trafford's boundary ---------------------------
22+
flood_risk_raw <- st_read("Risk_of_Flooding_from_Rivers_and_Sea.json") %>% # Downloaded file mentioned in NOTE 2
23+
st_make_valid() # The geometry returned in the data downloaded above needs correcting as there are overlapping vertices/self-intersections etc.
24+
25+
# Load boundary of Trafford ---------------------------
26+
trafford <- st_read("https://www.trafforddatalab.io/spatial_data/local_authority/2021/trafford_local_authority_full_resolution.geojson") %>%
27+
st_set_crs(4326) %>%
28+
select(-lat, -lon)
29+
30+
# Intersect data, leaving just flood risk data within Trafford's boundary and tidy up variables ---------------------------
31+
trafford_flood_risk <- st_intersection(flood_risk_raw, trafford) %>%
32+
rename(flood_risk = prob_4band,
33+
suitable_scale = suitability) %>%
34+
mutate(publication_date = as.character(as.POSIXct(pub_date, tz="UTC"))) %>%
35+
filter(st_geometry_type(geometry) != "POINT") %>% # Remove any point data as this will show up as a marker pin on the map which will be confusing. There seem to be 6 within the dataset.
36+
select(flood_risk, suitable_scale, publication_date, RoFRS_id = id)
1637

17-
# intersect data ---------------------------
18-
trafford_flood <- st_intersection(flood, trafford)
1938

2039
# write data ---------------------------
21-
st_write(trafford_flood, "trafford_flood_risk.geojson", driver = "GeoJSON")
40+
st_write(trafford_flood_risk, "trafford_flood_risk.geojson", driver = "GeoJSON")
41+
42+
sf_use_s2(is_sf_using_s2) # Reset whether sf is using S2 or R2 geometry calculations

flood_risk/styling.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
## Styling features ##
1+
## Styling flood risk features ##
22

33
# load packages ---------------------------
44
library(tidyverse); library(sf)
55

6-
# read data ---------------------------
7-
geojson <- st_read("https://www.traffordDataLab.io/open_data/flood_risk/trafford_flood_risk.geojson")
6+
# read un-styled, cleaned data ---------------------------
7+
geojson <- st_read("trafford_flood_risk.geojson")
88

99
# apply styles ---------------------------
1010
geojson_styles <- geojson %>%
1111
mutate(stroke =
1212
case_when(
13-
PROB_4BAND == "Very Low" ~ "#eff3ff",
14-
PROB_4BAND == "Low" ~ "#bdd7e7",
15-
PROB_4BAND == "Medium" ~ "#6baed6",
16-
PROB_4BAND == "High" ~ "#2171b5"),
13+
flood_risk == "Very Low" ~ "#bdd7e7",
14+
flood_risk == "Low" ~ "#6baed6",
15+
flood_risk == "Medium" ~ "#2171b5",
16+
flood_risk == "High" ~ "#3E4388"),
1717
`stroke-width` = 3,
1818
`stroke-opacity` = 1,
1919
fill = stroke,

flood_risk/thumbnail.png

-1.04 MB
Binary file not shown.

flood_risk/trafford_flood_risk.geojson

Lines changed: 2798 additions & 2376 deletions
Large diffs are not rendered by default.

flood_risk/trafford_flood_risk_styled.geojson

Lines changed: 2798 additions & 2376 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)