Skip to content

Commit c6c1efc

Browse files
committed
Population density for wards 2023
1 parent db2fc11 commit c6c1efc

File tree

4 files changed

+78
-33
lines changed

4 files changed

+78
-33
lines changed

demographics/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
| Old-age dependency ratio | 2021 | Best-fit ward | Census 2021 | Number of people aged 65 years or above as a percentage of the working age population (16-64 years). Higher percentages indicate a larger share of pensioners relative to the resident labour force. | [view](data/old_age_dependency_ratio.csv) | [view](code/old_age_dependency_ratio.R) |
1212
| Non-white ethnic group | 2021 | Best-fit ward | Census 2021 | Percentage of people identifying their ethnic group as either Asian or Asian British, Mixed ethnicity, Black or Black British or Chinese or other non-White ethnicity. Higher percentages indicate a larger proportion of residents self-identifying as of non-White ethnicity. | [view](data/bme.csv) | [view](code/bme.R) |
1313
| No people in household have English as a main language | 2021 | Best-fit ward | Census 2021 | Percentage of households with no occupants speaking English as their main language. Higher percentages indicate a larger proportion of households where no people in the household have English as a main language. | [view](data/non_english_speaking_households.csv) | [view](code/non_english_speaking_households.R) |
14-
| Single ethnicity households | 2021 | Best-fit ward | Census 2021 | Percentage of households where all occupants are of the same ethnic group. Higher percentages indicate a larger proportion of households with occupants belonging to the same ethnic group. | [view](data/single_ethnicity_households.csv) | [view](code/single_ethnicity_households.R) |
14+
| Single ethnicity households | 2021 | Best-fit ward | Census 2021 | Percentage of households where all occupants are of the same ethnic group. Higher percentages indicate a larger proportion of households with occupants belonging to the same ethnic group. | [view](data/single_ethnicity_households.csv) | [view](code/single_ethnicity_households.R) |
15+
| Population density per km sq | 2020 | Best-fit ward | Census 2021 | Number of people per square kilometre. Higher densities indicate a larger number of people living in an area per square kilometre. | [view](data/population_density.csv) | [view](code/population_density.R) |
+42-21
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
1-
# Demographics: Population density per km sq, 2020 #
1+
# Demographics: Population density per km sq, 2021 #
22

3-
# Source: ONS 2020 Mid-Year Population Estimates
4-
# URL: https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/wardlevelmidyearpopulationestimatesexperimental
3+
# Source: Census 2021
4+
# URL: https://www.nomisweb.co.uk/datasets/c2021ts001
55
# Licence: Open Government Licence
66

7-
library(tidyverse) ; library(sf) ; library(lwgeom) ; library(units) ; library(readxl) ; library(jsonlite)
7+
library(tidyverse) ; library(sf) ; library(jsonlite)
88

9-
codes <- fromJSON(paste0("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/WD19_LAD19_UK_LU/FeatureServer/0/query?where=LAD19NM%20like%20'%25", URLencode(toupper("Trafford"), reserved = TRUE), "%25'&outFields=WD19CD,LAD19NM&outSR=4326&f=json"), flatten = TRUE) %>%
9+
# OA to ward lookup #
10+
11+
# Source: ONS Open Geography Portal
12+
# Publisher URL: http://geoportal.statistics.gov.uk/
13+
# Licence: Open Government Licence 3.0
14+
15+
# Best-fit lookup between OAs and wards
16+
17+
18+
codes <- fromJSON(paste0("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/WD23_LAD23_UK_LU_DEC/FeatureServer/0/query?where=LAD23NM%20%3D%20'", URLencode(toupper("Trafford"), reserved = TRUE), "'&outFields=WD23CD,WD23NM,LAD23CD,LAD23NM&outSR=4326&f=json"), flatten = TRUE) %>%
19+
pluck("features") %>%
20+
as_tibble() %>%
21+
distinct(attributes.WD23CD) %>%
22+
pull(attributes.WD23CD)
23+
24+
25+
wards <- st_read(paste0("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/Wards_December_2023_Boundaries_UK_BFE/FeatureServer/0/query?where=",
26+
URLencode(paste0("WD23CD IN (", paste(shQuote(codes), collapse = ", "), ")")),
27+
"&outFields=WD23CD,WD23NM,Shape__Area&outSR=4326&f=json")) %>%
28+
#mutate(area = as.numeric(set_units(st_area(.), km^2))) %>%
29+
mutate(area = Shape__Area) %>%
30+
select(area_code = WD23CD, area)
31+
32+
33+
lookup <- fromJSON("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/OA21_WD23_LAD23_EW_LU/FeatureServer/0/query?where=LAD23NM%20%3D%20'TRAFFORD'&outFields=*&outSR=4326&f=json", flatten = TRUE) %>%
1034
pluck("features") %>%
1135
as_tibble() %>%
12-
distinct(attributes.WD19CD) %>%
13-
pull(attributes.WD19CD)
14-
15-
wards <- st_read(paste0("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/Wards_December_2019_Boundaries_UK_BFC_v2/FeatureServer/0/query?where=",
16-
URLencode(paste0("wd19cd IN (", paste(shQuote(codes), collapse = ", "), ")")),
17-
"&outFields=wd19cd,wd19nm&outSR=4326&f=geojson")) %>%
18-
mutate(area = as.numeric(set_units(st_area(.), km^2))) %>%
19-
select(area_code = WD19CD, area)
20-
21-
df <- read_csv("https://www.nomisweb.co.uk/api/v01/dataset/NM_2010_1.data.csv?geography=1656750701...1656750715,1656750717,1656750716,1656750718...1656750721&date=latest&gender=0&c_age=200&measures=20100") %>%
22-
select(area_code = GEOGRAPHY_CODE,
23-
area_name = GEOGRAPHY_NAME,
24-
`All Ages` = OBS_VALUE) %>%
36+
select(OA21CD = attributes.OA21CD, area_code = attributes.WD23CD, area_name = attributes.WD23NM)
37+
38+
39+
df <- read_csv("https://www.nomisweb.co.uk/api/v01/dataset/NM_2021_1.data.csv?date=latest&geography=629174437...629175131,629304895...629304912,629315184...629315186,629315192...629315198,629315220,629315233,629315244,629315249,629315255,629315263,629315265,629315274,629315275,629315278,629315281,629315290,629315295,629315317,629315327&c2021_restype_3=0&measures=20100") %>%
40+
left_join(lookup, by = c("GEOGRAPHY_CODE" = "OA21CD")) %>%
41+
select(period = DATE_NAME,
42+
area_code, area_name,
43+
value = OBS_VALUE) %>%
44+
group_by(period, area_code, area_name) %>%
45+
summarise(pop = sum(value)) %>%
46+
ungroup() %>%
2547
left_join(wards, by = "area_code") %>%
26-
mutate(value = round(`All Ages`/area, 1),
27-
period = as.Date("2020-06-30", format = '%Y-%m-%d'),
48+
mutate(value = round((pop/area)*1000000, 0),
2849
indicator = "Population density per km sq",
2950
measure = "Density",
30-
unit = "Persons") %>%
51+
unit = "persons/km^2") %>%
3152
select(area_code, area_name, indicator, period, measure, unit, value)
3253

3354
write_csv(df, "../data/population_density.csv")
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
area_code,area_name,indicator,period,measure,unit,value
2+
E05015239,Altrincham,Population density per km sq,2021,Density,persons/km^2,3622
3+
E05015240,Ashton upon Mersey,Population density per km sq,2021,Density,persons/km^2,4500
4+
E05015241,Bowdon,Population density per km sq,2021,Density,persons/km^2,456
5+
E05015242,Broadheath,Population density per km sq,2021,Density,persons/km^2,3331
6+
E05015243,Brooklands,Population density per km sq,2021,Density,persons/km^2,4716
7+
E05015244,Bucklow-St Martins,Population density per km sq,2021,Density,persons/km^2,772
8+
E05015245,Davyhulme,Population density per km sq,2021,Density,persons/km^2,2657
9+
E05015246,Flixton,Population density per km sq,2021,Density,persons/km^2,2505
10+
E05015247,Gorse Hill & Cornbrook,Population density per km sq,2021,Density,persons/km^2,1320
11+
E05015248,Hale,Population density per km sq,2021,Density,persons/km^2,4044
12+
E05015249,Hale Barns & Timperley South,Population density per km sq,2021,Density,persons/km^2,1269
13+
E05015250,Longford,Population density per km sq,2021,Density,persons/km^2,3478
14+
E05015251,Lostock & Barton,Population density per km sq,2021,Density,persons/km^2,2295
15+
E05015252,Manor,Population density per km sq,2021,Density,persons/km^2,4366
16+
E05015253,Old Trafford,Population density per km sq,2021,Density,persons/km^2,9578
17+
E05015254,Sale Central,Population density per km sq,2021,Density,persons/km^2,3357
18+
E05015255,Sale Moor,Population density per km sq,2021,Density,persons/km^2,3830
19+
E05015256,Stretford & Humphrey Park,Population density per km sq,2021,Density,persons/km^2,3566
20+
E05015257,Timperley Central,Population density per km sq,2021,Density,persons/km^2,4921
21+
E05015258,Timperley North,Population density per km sq,2021,Density,persons/km^2,5326
22+
E05015259,Urmston,Population density per km sq,2021,Density,persons/km^2,3045

demographics/meta.csv

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
indicator,period,geography,source,description,data,code
2-
Total resident population,2021,Best-fit ward,Census 2021,Count of residents living in each ward. Higher counts indicate larger resident populations.,https://www.trafforddatalab.io/ward_data/demographics/data/total_resident_population.csv,https://www.trafforddatalab.io/ward_data/demographics/code/total_resident_population.R
3-
Population aged 0-15 years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 0-15 years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_0-15_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_0-15_years.R
4-
Population aged 16-64 years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 16-64 years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_16-64_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_16-64_years.R
5-
Population aged 20-44 years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 20-44 years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_20-44_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_20-44_years.R
6-
Population aged 65 or more years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 65 or more years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_65_or_more_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_65_or_more_years.R
7-
Population aged 80 or more years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 80 or more years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_80_or_more_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_80_or_more_years.R
8-
Old-age dependency ratio,2021,Best-fit ward,Census 2021,Number of people aged 65 years or above as a percentage of the working age population (16-64 years). Higher percentages indicate a larger share of pensioners relative to the resident labour force.,https://www.trafforddatalab.io/ward_data/demographics/data/old_age_dependency_ratio.csv,https://www.trafforddatalab.io/ward_data/demographics/code/old_age_dependency_ratio.R
9-
Ethnically Diverse Communities,2021,Best-fit ward,Census 2021,"Percentage of people identifying their ethnic group as either Asian or Asian British, Mixed or Multiple ethnic groups, Black, Black British, Caribbean or African or other non-White ethnicity. Higher percentages indicate a larger proportion of residents self-identifying as of non-White ethnicity.",https://www.trafforddatalab.io/ward_data/demographics/data/ethnically_diverse_communities.csv,https://www.trafforddatalab.io/ward_data/demographics/code/ethnically_diverse_communities.R
10-
No people in household have English as a main language,2021,Best-fit ward,Census 2021,Percentage of households with no occupants speaking English as their main language. Higher percentages indicate a larger proportion of households where no people in the household have English as a main language.,https://www.trafforddatalab.io/ward_data/demographics/data/non_english_speaking_households.csv,https://www.trafforddatalab.io/ward_data/demographics/code/non_english_speaking_households.R
11-
Single ethnicity households,2021,Best-fit ward,Census 2021,Percentage of households where all occupants are of the same ethnic group. Higher percentages indicate a larger proportion of households with occupants belonging to the same ethnic group.,https://www.trafforddatalab.io/ward_data/demographics/data/single_ethnicity_households.csv,https://www.trafforddatalab.io/ward_data/demographics/code/single_ethnicity_households.R
1+
indicator,period,geography,source,description,data,code
2+
Total resident population,2021,Best-fit ward,Census 2021,Count of residents living in each ward. Higher counts indicate larger resident populations.,https://www.trafforddatalab.io/ward_data/demographics/data/total_resident_population.csv,https://www.trafforddatalab.io/ward_data/demographics/code/total_resident_population.R
3+
Population aged 0-15 years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 0-15 years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_0-15_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_0-15_years.R
4+
Population aged 16-64 years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 16-64 years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_16-64_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_16-64_years.R
5+
Population aged 20-44 years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 20-44 years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_20-44_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_20-44_years.R
6+
Population aged 65 or more years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 65 or more years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_65_or_more_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_65_or_more_years.R
7+
Population aged 80 or more years,2021,Best-fit ward,Census 2021,Proportion of the total resident population aged 80 or more years. Higher percentages indicate a larger proportion of the resident population belong to that age group.,https://www.trafforddatalab.io/ward_data/demographics/data/population_80_or_more_years.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_80_or_more_years.R
8+
Old-age dependency ratio,2021,Best-fit ward,Census 2021,Number of people aged 65 years or above as a percentage of the working age population (16-64 years). Higher percentages indicate a larger share of pensioners relative to the resident labour force.,https://www.trafforddatalab.io/ward_data/demographics/data/old_age_dependency_ratio.csv,https://www.trafforddatalab.io/ward_data/demographics/code/old_age_dependency_ratio.R
9+
Ethnically Diverse Communities,2021,Best-fit ward,Census 2021,"Percentage of people identifying their ethnic group as either Asian or Asian British, Mixed or Multiple ethnic groups, Black, Black British, Caribbean or African or other non-White ethnicity. Higher percentages indicate a larger proportion of residents self-identifying as of non-White ethnicity.",https://www.trafforddatalab.io/ward_data/demographics/data/ethnically_diverse_communities.csv,https://www.trafforddatalab.io/ward_data/demographics/code/ethnically_diverse_communities.R
10+
No people in household have English as a main language,2021,Best-fit ward,Census 2021,Percentage of households with no occupants speaking English as their main language. Higher percentages indicate a larger proportion of households where no people in the household have English as a main language.,https://www.trafforddatalab.io/ward_data/demographics/data/non_english_speaking_households.csv,https://www.trafforddatalab.io/ward_data/demographics/code/non_english_speaking_households.R
11+
Single ethnicity households,2021,Best-fit ward,Census 2021,Percentage of households where all occupants are of the same ethnic group. Higher percentages indicate a larger proportion of households with occupants belonging to the same ethnic group.,https://www.trafforddatalab.io/ward_data/demographics/data/single_ethnicity_households.csv,https://www.trafforddatalab.io/ward_data/demographics/code/single_ethnicity_households.R
12+
Population density per km sq,2021,Best-fit ward,Census 2021,Number of people per square kilometre. Higher densities indicate a larger number of people living in an area per square kilometre.,https://www.trafforddatalab.io/ward_data/demographics/data/population_density.csv,https://www.trafforddatalab.io/ward_data/demographics/code/population_density.R

0 commit comments

Comments
 (0)