Skip to content

Commit

Permalink
updating file paths and BUC shapefile with updated map
Browse files Browse the repository at this point in the history
created new map with BUC shapefile for 21/22 CCG trust map
  • Loading branch information
faaiz-25 committed Nov 29, 2023
1 parent 41b66e9 commit 7d9f430
Show file tree
Hide file tree
Showing 43 changed files with 403,249 additions and 24 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions 02-geomapping-ICS.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ regions_spdf = SpatialPolygonsDataFrame(region_s, data.frame(region_full))

## Load STP shapefile
# Source: https://geoportal.statistics.gov.uk/datasets/clinical-commissioning-groups-april-2020-full-clipped-boundaries-en/explore?location=52.950000%2C-2.000000%2C7.02
stp_spdf <- readOGR("/Users/muhammad-faaiz.shanawas/Documents/Live Projects/Cyber Map/Shapefiles/Sustainability_and_Transformation_Partnerships_(April_2020)_Boundaries_EN_BUC/Sustainability_and_Transformation_Partnerships_(April_2020)_Boundaries_EN_BUC.shp")
stp_spdf <- readOGR("./Inputs/shapefiles/20_21/Sustainability_and_Transformation_Partnerships_(April_2020)_Boundaries_EN_BUC/Sustainability_and_Transformation_Partnerships_(April_2020)_Boundaries_EN_BUC.shp")

proj4string(stp_spdf) <- CRS("+init=epsg:27700") # BNG projection system

Expand All @@ -85,7 +85,7 @@ stp_spdf <- stp_spdf %>% sp::spTransform(CRS("+init=epsg:4326")) # reproject to

## Load CCG shapefile
# Source: https://geoportal.statistics.gov.uk/datasets/clinical-commissioning-groups-april-2020-full-clipped-boundaries-en/explore?location=52.950000%2C-2.000000%2C7.02
ccg_spdf <- readOGR("./Inputs/shapefile/Clinical_Commissioning_Groups_(April_2020)_EN_BFC_V2.shp")
ccg_spdf <- readOGR("./Inputs/shapefiles/20_21/Clinical_Commissioning_Groups_(April_2020)_EN_BFC_V2.shp")

proj4string(ccg_spdf) <- CRS("+init=epsg:27700") # BNG projection system

Expand Down
33 changes: 16 additions & 17 deletions 02-geomapping-ICS_21_22.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library(leaflet)


## Load 'curated' DSPT file
data <- read.csv("/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/DSPT_CCG_21_22_snapshot09_09_22.csv")
data <- read.csv("./data/DSPT Snapshots/21_22/DSPT_CCG_21_22_snapshot09_09_22.csv")
data <- data[-107,]

dsptlevels=c("21/22 Standards Exceeded","21/22 Standards Met","21/22 Approaching Standards","21/22 Standards Not Met","21/22 Not Published")
Expand All @@ -50,7 +50,7 @@ data$Short.Status = factor(data$Status,dsptlevels)

## Load STP shapefile
# Source: https://geoportal.statistics.gov.uk/datasets/clinical-commissioning-groups-april-2020-full-clipped-boundaries-en/explore?location=52.950000%2C-2.000000%2C7.02
stp_spdf <- readOGR("/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/Inputs/shapefile/STP_APR_2021_EN_BUC_V2.shp")
stp_spdf <- readOGR("./Inputs/shapefiles/21_22/STP_APR_2021_EN_BUC_V2.shp")

proj4string(stp_spdf) <- CRS("+init=epsg:27700") # BNG projection system

Expand All @@ -65,7 +65,7 @@ stp_data = stp_spdf@data

## Load CCG shapefile

ccg_spdf <- readOGR("/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/Inputs/shapefile/CCG_APR_2021_EN_BFC.shp")
ccg_spdf <- readOGR("./Inputs/shapefiles/21_22/CCG_APR_2021_EN_BUC.shp")

proj4string(ccg_spdf) <- CRS("+init=epsg:27700") # BNG projection system

Expand All @@ -76,7 +76,7 @@ ccg_spdf <- ccg_spdf %>% sp::spTransform(CRS("+init=epsg:4326")) # reproject to
# Write to shapefile
#writeOGR(ccg_spdf, layer = 'myshp_simplified', 'C:/temp', driver="ESRI Shapefile")

region_spdf = readOGR('/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/Inputs/shapefile/NHS_England_Regions_(April_2020)_Boundaries_EN_BUC.shp')
region_spdf = readOGR('./Inputs/shapefiles/20_21/NHS_England_Regions_(April_2020)_Boundaries_EN_BUC.shp')
proj4string(region_spdf) <- CRS("+init=epsg:27700") # BNG projection system

region_spdf@proj4string # check system
Expand All @@ -85,11 +85,11 @@ region_spdf <- region_spdf %>% sp::spTransform(CRS("+init=epsg:4326")) # reproje

region_full <- region_spdf

region_s <- rgeos::gSimplify(region_full,tol=0.01, topologyPreserve=FALSE)
###region_s <- rgeos::gSimplify(region_full,tol=0.01, topologyPreserve=FALSE)

# Create a spatial polygon data frame (includes shp attributes)
regions_spdf = SpatialPolygonsDataFrame(region_s, data.frame(region_full))

###regions_spdf = SpatialPolygonsDataFrame(region_s, data.frame(region_full))
regions_spdf = region_spdf


##Load correspondence from ODS to ONS codes
Expand All @@ -102,7 +102,7 @@ regions_spdf = SpatialPolygonsDataFrame(region_s, data.frame(region_full))
# Create a points shapefile for Trusts
##########+
##########+###################################
trusts_data = read.csv("/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/DSPT_trusts_21_22_snapshot09_09_22.csv")
trusts_data = read.csv("./data/DSPT Snapshots/21_22/DSPT_trusts_21_22_snapshot09_09_22.csv")
trusts_data <- subset(trusts_data, !(ODS.Code %in% c('RBZ', 'RW6', 'RTV')))


Expand All @@ -119,20 +119,19 @@ trust_spdf_points <- sp::SpatialPointsDataFrame(
#Further prep
#############################################
# Join DSPT data and ONS code
lookupdata = read.csv('/Users/muhammad-faaiz.shanawas/Documents/Github/open-cyber/data/Clinical_Commissioning_Group_to_STPs_(April_2021)_Lookup_in_England.csv')
lookupdata = read.csv('./data/auxiliary/21_22/Clinical_Commissioning_Group_to_STPs_(April_2021)_Lookup_in_England.csv')
data_merged = left_join(data, lookupdata, by = c("ODS.Code" = "CCG21CDH"))
data_merged = data_merged[-107,]


#load in ccg-stp-region lookup data
regions_lookup = read.csv('/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/Clinical_Commissioning_Group_to_STP_and_NHS_England_(Region)_(April_2021)_Lookup_in_England.csv')
regions_lookup = read.csv('./data/auxiliary/21_22/Clinical_Commissioning_Group_to_STP_and_NHS_England_(Region)_(April_2021)_Lookup_in_England.csv')
data_regions = unique(select(regions_lookup, 'STP21CD', 'STP21NM', 'NHSER21NM'))

# Join the reduced DSPT info with the CCG shapefile
ccg_spdf@data <- left_join(ccg_spdf@data,data_merged,by=c("CCG21CD"="CCG21CD"))
data_ccg_spdf <- ccg_spdf@data


#merge and assign to stp_spdf data
stp_spdfdata = stp_spdf@data
stp_spdfdata = merge(stp_spdfdata, select(data_regions, 'STP21CD', 'NHSER21NM'), by = "STP21CD", all = TRUE)
Expand Down Expand Up @@ -293,7 +292,7 @@ m03

# save the widget in a html file if needed.
#library(htmlwidgets)
saveWidget(m04, "ICS_composite_map1_21_22.html")
saveWidget(m03, "outputs/ICS_composite_map1_21_22_vrun20231129.html")



Expand All @@ -302,12 +301,12 @@ saveWidget(m04, "ICS_composite_map1_21_22.html")
# Summary metric
#############################################
#get the stp codes for trusts from etr
etr = read.csv('/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/etr.csv', header = FALSE)
etr = read.csv('./data/auxiliary/21_22/etr.csv', header = FALSE)
etr = etr[,c('V1', 'V4')]
etr = select(etr, 'ODS.Code' = 'V1', 'STP21CDH' = 'V4')

#get the final 4 stp codes of the 4 care trusts from ect (modified to change column names and select relevant columns)
ect = read.csv('/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/ect_modified_21_22.csv')
ect = read.csv('./data/auxiliary/21_22/ect_modified_21_22.csv')
ect = select(ect, 'ODS.Code', 'STP21CDH')

etr_ect = rbind(etr, ect)
Expand All @@ -328,7 +327,7 @@ trusts_data_merged = left_join(trusts_data_merged, stp_codes)


#load in ccg-stp-region lookup data
regions_lookup = read.csv('/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/Clinical_Commissioning_Group_to_STP_and_NHS_England_(Region)_(April_2021)_Lookup_in_England.csv')
regions_lookup = read.csv('./data/auxiliary/21_22/Clinical_Commissioning_Group_to_STP_and_NHS_England_(Region)_(April_2021)_Lookup_in_England.csv')
data_regions = unique(select(regions_lookup, 'STP21CD', 'STP21NM', 'NHSER21NM'))

trusts_data_merged = left_join(trusts_data_merged, data_regions)
Expand Down Expand Up @@ -621,7 +620,7 @@ m07
#load in the snapshot data to create summary tables and charts
###############################################################
#load in the snapshot data and filter for the 5 relevant CSUs
data_snapshot = read.csv('/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/data/DSPT search results 09_09_2022 12_44_07.csv')
data_snapshot = read.csv('./data/DSPT Snapshots/21_22/DSPT search results 09_09_2022 12_44_07.csv')
data_summary = data_snapshot %>% select('Organisation.Name', 'Status', 'Primary.Sector')
data_summary = data_summary %>% filter(Primary.Sector == "Commissioning Support Unit (CSU)")
data_csu = data_summary %>% filter(str_detect(Organisation.Name, 'CSU'))
Expand Down Expand Up @@ -655,4 +654,4 @@ ct_final = ctable(data_s$Primary.Sector, data_s$Status,
prop = "r", chisq = FALSE, headings = FALSE
)
ct_final %>% print(method="browser")
ct_final %>% print(file=paste0("/Users/muhammad-faaiz.shanawas/Documents/GitHub/open-cyber/cross_table_summary_21_22",Sys.Date(),".html"))
ct_final %>% print(file=paste0("./outputs/cross_table_summary_21_22",Sys.Date(),".html"))
4 changes: 2 additions & 2 deletions 02-geomapping-ICS_22_23.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ trust_spdf_points <- sp::SpatialPointsDataFrame(
#Further prep
#############################################
# Join DSPT data and ONS code
lookupdata = read.csv('./data/aux/22_23/Sub_ICB_Locations_to_Integrated_Care_Boards_to_NHS_England_(Region)_(April_2023)_Lookup_in_England (1).csv')
lookupdata = read.csv('./data/auxiliary/22_23/Sub_ICB_Locations_to_Integrated_Care_Boards_to_NHS_England_(Region)_(April_2023)_Lookup_in_England (1).csv')
lookup_icb = lookupdata[!duplicated(lookupdata$ICB23CD), ]


Expand Down Expand Up @@ -363,4 +363,4 @@ m04

# save the widget in a html file if needed.
#library(htmlwidgets)
saveWidget(m04, "./outputs/icb_composite_map_16_11_23.html")
saveWidget(m04, "./outputs/icb_composite_map_16_11_23.html")
2 changes: 1 addition & 1 deletion 21_22.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Summary statistics from the DSPT 2021/22 toolkit are shown.
The compliance of individual CCGs and Trusts are mapped below, with ICS boundaries. Toggle the boxes on the top right-hand side to add layers.


<iframe src="./outputs/ccg_trusts_map_03_10_22.html" height="600px" width="100%" style="border:none;"></iframe>
<iframe src="./outputs/ccg_trusts_map_03_10_22_BUC.html" height="600px" width="100%" style="border:none;"></iframe>

<hr class="nhsuk-u-margin-top-0 nhsuk-u-margin-bottom-6">

Expand Down
Binary file added data/.DS_Store
Binary file not shown.
Binary file added data/DSPT Snapshots/.DS_Store
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 7d9f430

Please sign in to comment.