Return boundary data at a specified level and area from the ONS OG API
bounds.Rd
Return boundary data at a specified level and area from the ONS OG API
Usage
bounds(
lookup_level,
within_level = NULL,
within_names = NULL,
within_codes = NULL,
lookup_year = NULL,
within_year = NULL,
opts = boundr_options(),
geometry = c("boundaries", "centroids")
)
Arguments
- lookup_level
character. Lower level area code eg "lsoa", "wd", "lad".
- within_level
character. Higher level area code eg "lad", "cty", "icb". (That is, higher (conceptually) than
lookup_level
; aka larger thanlookup
!). If not supplied, this uses the defaultNULL
, and just data forlookup_level
will be returned. In this case,within_names
andwithin_codes
(if supplied) will instead be taken to refer to, and used to filter at, thelookup_level
level.- within_names, within_codes
character. In order to restrict data returned to a specific area, either
within_names
orwithin_codes
must be provided. Otherwise all available boundaries at that level will be retrieved. Use place names eg "Essex" to restrict to a certain geographical area. Or use ONS area codes eg "W02000103" likewise (this is useful with wards, where there are many that share identical names). To use this argument to filterwithin_level
, thewithin_level
must be specified! Otherwise{boundr}
will apply them tolookup_level
instead. See examples. Vectors of multiple names or multiple codes can be supplied. If you supply bothwithin_names
andwithin_codes
, onlywithin_names
will be used; (within_codes
will be ignored).- lookup_year
numeric or character. A specific year for data relating to
lookup_level
, if you need it. Defaults toNULL
, which then aims to return data for the most recent year available. Provide as YYYY.- within_year
numeric or character. A specific year for data relating to
within_level
, if you need it. Defaults toNULL
, which then aims to return data for the most recent year available. Provide as YYYY.- opts
Should be set with the
boundr_options()
function. See?boundr_options
for detail on what can be set by the user, and on the default values.- geometry
character. Two options: "boundaries" (the default) and "centroids". By default,
bounds()
will return area boundaries. Set this explicitly to "centroids" to get area centroids instead.
Examples
bounds("msoa", "lad", "Swansea")
#> Simple feature collection with 30 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -4.333587 ymin: 51.53577 xmax: -3.842747 ymax: 51.77423
#> Geodetic CRS: WGS 84
#> # A tibble: 30 × 8
#> msoa21cd msoa21nm lad24cd lad24nm msoa21nmw msoa21hclnm msoa21hclnmw
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 W02000168 Swansea 001 W06000011 Swansea Abertawe 001 Pontarddul… Pontarddula…
#> 2 W02000169 Swansea 002 W06000011 Swansea Abertawe 002 Clydach & … Clydach a M…
#> 3 W02000170 Swansea 003 W06000011 Swansea Abertawe 003 Morriston … Gogledd Tre…
#> 4 W02000171 Swansea 004 W06000011 Swansea Abertawe 004 Llangyfela… Llangyfelac…
#> 5 W02000172 Swansea 005 W06000011 Swansea Abertawe 005 Gorseinon Gorseinon
#> 6 W02000173 Swansea 006 W06000011 Swansea Abertawe 006 Birchgrove Gellifedw
#> 7 W02000174 Swansea 007 W06000011 Swansea Abertawe 007 Loughor Casllwchwr
#> 8 W02000175 Swansea 008 W06000011 Swansea Abertawe 008 Morriston … De Treforys
#> 9 W02000176 Swansea 009 W06000011 Swansea Abertawe 009 Mynydd-bach Mynydd-bach
#> 10 W02000177 Swansea 010 W06000011 Swansea Abertawe 010 Llansamlet Llansamlet
#> # ℹ 20 more rows
#> # ℹ 1 more variable: geometry <MULTIPOLYGON [°]>
bounds("wd", "lad", "Shepway", within_year = 2016) # Shepway no longer exists
#> Simple feature collection with 13 features and 4 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 0.7768709 ymin: 50.91048 xmax: 1.221268 ymax: 51.205
#> Geodetic CRS: WGS 84
#> # A tibble: 13 × 5
#> wd16cd wd16nm lad16cd lad16nm geometry
#> <chr> <chr> <chr> <chr> <POLYGON [°]>
#> 1 E05010015 Broadmead E07000… Shepway ((1.155543 51.08448, 1.1…
#> 2 E05010016 Cheriton E07000… Shepway ((1.159752 51.10128, 1.1…
#> 3 E05010017 East Folkestone E07000… Shepway ((1.184824 51.09986, 1.1…
#> 4 E05010018 Folkestone Central E07000… Shepway ((1.177906 51.07553, 1.1…
#> 5 E05010019 Folkestone Harbour E07000… Shepway ((1.184824 51.09986, 1.1…
#> 6 E05010020 Hythe E07000… Shepway ((1.119319 51.08961, 1.1…
#> 7 E05010021 Hythe Rural E07000… Shepway ((1.036358 51.08556, 1.0…
#> 8 E05010022 New Romney E07000… Shepway ((0.9804397 51.00251, 0.…
#> 9 E05010023 North Downs East E07000… Shepway ((1.147638 51.17718, 1.1…
#> 10 E05010024 North Downs West E07000… Shepway ((1.097309 51.18892, 1.0…
#> 11 E05010025 Romney Marsh E07000… Shepway ((1.035288 51.04665, 1.0…
#> 12 E05010026 Sandgate & West Folkesto… E07000… Shepway ((1.155534 51.08386, 1.1…
#> 13 E05010027 Walland & Denge Marsh E07000… Shepway ((0.8944822 51.03699, 0.…
bounds("rgn", opts = boundr_options(resolution = "BUC"))
#> Simple feature collection with 9 features and 2 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -6.360297 ymin: 49.88234 xmax: 1.763706 ymax: 55.81121
#> Geodetic CRS: WGS 84
#> # A tibble: 9 × 3
#> rgn23cd rgn23nm geometry
#> <chr> <chr> <MULTIPOLYGON [°]>
#> 1 E12000001 North East (((-1.401114 55.01121, -1.404909 55.00954,…
#> 2 E12000002 North West (((-3.242936 54.09894, -3.252463 54.09577,…
#> 3 E12000003 Yorkshire and The Humber (((-0.5207704 53.68522, -0.5357478 53.6812…
#> 4 E12000004 East Midlands (((-0.248476 53.59366, -0.2513956 53.58465…
#> 5 E12000005 West Midlands (((-1.860821 53.18847, -1.812615 53.15441,…
#> 6 E12000006 East of England (((0.6458286 51.53922, 0.6274273 51.53309,…
#> 7 E12000007 London (((-0.01191868 51.68088, -0.01225969 51.64…
#> 8 E12000008 South East (((-1.55515 50.71435, -1.551177 50.70614, …
#> 9 E12000009 South West (((-6.349051 49.89822, -6.328423 49.89246,…
bounds("par", "lad", "Isles of Scilly") # par = "parish"
#> Simple feature collection with 5 features and 4 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -6.418667 ymin: 49.86479 xmax: -6.244608 ymax: 49.98065
#> Geodetic CRS: WGS 84
#> # A tibble: 5 × 5
#> par23cd par23nm lad23cd lad23nm geometry
#> <chr> <chr> <chr> <chr> <MULTIPOLYGON [°]>
#> 1 E04012729 Bryher E06000053 Isles of Scilly (((-6.386119 49.93495, -6.385…
#> 2 E04012730 St Agnes E06000053 Isles of Scilly (((-6.398976 49.8649, -6.4004…
#> 3 E04012731 St Martin's E06000053 Isles of Scilly (((-6.273013 49.94357, -6.274…
#> 4 E04012732 St Mary's E06000053 Isles of Scilly (((-6.280232 49.91312, -6.280…
#> 5 E04012733 Tresco E06000053 Isles of Scilly (((-6.361791 49.93116, -6.362…
bounds("spr")
#> Warning: GDAL Message 1: organizePolygons() received a polygon with more than 100 parts. The processing may be really slow. You can skip the processing by setting METHOD=SKIP.
#> Simple feature collection with 8 features and 2 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -8.649996 ymin: 54.63326 xmax: -0.7246158 ymax: 60.86077
#> Geodetic CRS: WGS 84
#> # A tibble: 8 × 3
#> spr22cd spr22nm geometry
#> <chr> <chr> <MULTIPOLYGON [°]>
#> 1 S17000011 Highlands and Islands (((-5.572266 55.28656, -5.570243 55.28481, -5…
#> 2 S17000012 Lothian (((-3.17174 55.9875, -3.17105 55.98732, -3.17…
#> 3 S17000013 Mid Scotland and Fife (((-3.302574 56.03094, -3.302508 56.03033, -3…
#> 4 S17000014 North East Scotland (((-2.531457 56.71581, -2.530777 56.71507, -2…
#> 5 S17000015 South Scotland (((-4.085281 54.7686, -4.084491 54.7683, -4.0…
#> 6 S17000018 West Scotland (((-5.118861 55.42869, -5.118397 55.42741, -5…
#> 7 S17000019 Central Scotland (((-3.795887 56.10006, -3.795648 56.09964, -3…
#> 8 S17000020 Glasgow (((-4.271141 55.9281, -4.270303 55.92808, -4.…
bounds("npark", within_names = "Bannau Brycheiniog")
#> Simple feature collection with 1 feature and 2 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -3.989641 ymin: 51.70209 xmax: -2.952245 ymax: 52.07827
#> Geodetic CRS: WGS 84
#> # A tibble: 1 × 3
#> npark22cd npark22nm geometry
#> <chr> <chr> <POLYGON [°]>
#> 1 W18000001 Bannau Brycheiniog ((-3.120246 52.07322, -3.119622 52.0728, -3.1202…
bounds("msoa", "utla", "Swindon", geometry = "centroids")
#> Simple feature collection with 27 features and 5 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -1.841969 ymin: 51.52607 xmax: -1.711772 ymax: 51.63355
#> Geodetic CRS: WGS 84
#> # A tibble: 27 × 6
#> msoa21cd msoa21nm msoa21hclnm utla23cd utla23nm geometry
#> <chr> <chr> <chr> <chr> <chr> <POINT [°]>
#> 1 E02003227 Swindon 016 Walcot East E060000… Swindon (-1.755953 51.56128)
#> 2 E02003221 Swindon 010 Gorse Hill E060000… Swindon (-1.778586 51.57297)
#> 3 E02003235 Swindon 024 Lawn & Eas… E060000… Swindon (-1.771018 51.54633)
#> 4 E02003226 Swindon 015 Central No… E060000… Swindon (-1.780904 51.5642)
#> 5 E02006847 Swindon 026 Mouldon Hi… E060000… Swindon (-1.826195 51.59848)
#> 6 E02003222 Swindon 011 Roughmoor E060000… Swindon (-1.840047 51.5718)
#> 7 E02003214 Swindon 003 Penhill E060000… Swindon (-1.782552 51.59257)
#> 8 E02003224 Swindon 013 Covingham E060000… Swindon (-1.734986 51.56627)
#> 9 E02003232 Swindon 021 Kingshill … E060000… Swindon (-1.792952 51.5512)
#> 10 E02003219 Swindon 008 Broad Blun… E060000… Swindon (-1.795708 51.60868)
#> # ℹ 17 more rows