Skip to content

Commit d433241

Browse files
committed
Updated the Trafford pharmacies dataset to include the locality that the pharmacy is located within.
1 parent 07f4654 commit d433241

3 files changed

Lines changed: 129 additions & 119 deletions

File tree

pharmacies/pre-processing.R

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,24 @@ sf <- df_with_coords %>%
4747
st_as_sf(coords = c("lon", "lat")) %>%
4848
st_set_crs(4326)
4949

50+
# Create Trafford-specific version containing localities
51+
sf_trafford <- sf %>%
52+
filter(health_and_wellbeing_board == "Trafford") %>% # NOTE: There are a few pharmacies where the value of health_and_wellbeing_board differs from la_name, therefore I'm using the former as the filter.
53+
mutate(locality = case_when(
54+
ward_name %in% c("Ashton upon Mersey", "Brooklands", "Manor", "Sale Central", "Sale Moor") ~ "Central",
55+
ward_name %in% c("Gorse Hill & Cornbrook", "Longford", "Lostock & Barton", "Old Trafford", "Stretford & Humphrey Park") ~ "North",
56+
ward_name %in% c("Altrincham", "Bowdon", "Broadheath", "Hale", "Hale Barns & Timperley South", "Timperley Central", "Timperley North") ~ "South",
57+
ward_name %in% c("Bucklow-St Martins", "Davyhulme", "Flixton", "Urmston") ~ "West")) %>%
58+
relocate(locality, .after = ward_name)
59+
5060

5161
# Write data ---------------------------
62+
# First remove the old GeoJSON files
5263
file.remove(c("gm_pharmacies.geojson",
5364
"trafford_pharmacies.geojson"))
5465

55-
# NOTE: There are a few pharmacies where the value of health_and_wellbeing_board differs from la_name, therefore I'm using the former as the filter.
5666
write_sf(sf, "gm_pharmacies.geojson", driver = "GeoJSON")
57-
write_sf(sf %>% filter(health_and_wellbeing_board == "Trafford"), "trafford_pharmacies.geojson", driver = "GeoJSON")
58-
5967
write_csv(st_set_geometry(sf, value = NULL), "gm_pharmacies.csv")
60-
write_csv(st_set_geometry(sf, value = NULL) %>% filter(health_and_wellbeing_board == "Trafford"), "trafford_pharmacies.csv")
68+
69+
write_sf(sf_trafford, "trafford_pharmacies.geojson", driver = "GeoJSON")
70+
write_csv(st_set_geometry(sf_trafford, value = NULL), "trafford_pharmacies.csv")

0 commit comments

Comments
 (0)