Return boundary data at a specified level and area from the ONS OG API
Usage
bounds(
lookup,
within = NULL,
within_names = NULL,
within_codes = NULL,
return_width = c("tidy", "full", "minimal"),
lookup_year = NULL,
within_year = NULL,
country_filter = c("UK|GB|EW|EN|SC|WA", "UK", "GB", "EW", "EN", "SC", "WA"),
resolution = c("BGC", "BSC", "BUC", "BFC", "BFE"),
option = NULL,
crs = 4326
)
Arguments
- lookup
character. Lower level area code eg "lsoa", "wd", "lad". Equivalent to the
lookup
parameter inbounds()
.- within
character. Higher level area code eg "lad", "cty". Equivalent to the
within
parameter inbounds()
.- 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 boundaries within the country at that level will be retrieved. Use place names eg "Essex" to restrict to a certain geographical area. Use ONS area codes eg "W02000103" likewise (this is useful with wards, where there are many that share identical names). A vector of multiple names or codes can be supplied.- return_width
character. How many of the possible columns in the returned table to keep. Options are "tidy", "full" or "minimal".
- lookup_year
numeric or character. A specific year for data relating to parameter
x
, if needed. Defaults toNULL
, which will return the most recent data.- within_year
numeric or character. A specific year for data relating to parameter
y
, if needed. Defaults toNULL
, which will return the most recent data.- country_filter
character. Open Geography datasets are sometimes available just within certain countries. Specify a country code if you want your results restricted to a certain country only - eg "WA" for Wales, "EW" for England and Wales. By default returns all options.
- resolution
character. See argument options for available options. How generalised should the boundary be, and whether coastal boundaries should adhere to the coastline or to the full territorial extent. BGC by default (G = Generalised (20m), C = limited to the coastline.) F indicates Full resolution; S indicates Super-generalised (200m); U indicates Ultra- generalised (500m) boundary resolution. Use E instead of C for full extent boundaries (e.g. BFE). Not all combinations are available.
- option
numeric. Defaults to 1, which means that the URL will just be the first one from the list of possible services resulting from the level and year filters above. If this does not give you what you want, you can run the script again with a different option from the list.
- crs
the Coordinate Reference System (CRS) code to use. 4326 by default.
Examples
bounds("msoa", "lad", "Swansea")
#> Joining with `by = join_by(msoa21nm)`
#> Simple feature collection with 30 features and 7 fields
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: -4.333587 ymin: 51.53577 xmax: -3.842747 ymax: 51.77423
#> Geodetic CRS: WGS 84
#> First 10 features:
#> lad23cd lad23nm msoa21nm msoa21cd msoa21nmw msoa21hclnm
#> 1 W06000011 Swansea Swansea 001 W02000168 Abertawe 001 Pontarddulais
#> 2 W06000011 Swansea Swansea 002 W02000169 Abertawe 002 Clydach & Mawr
#> 3 W06000011 Swansea Swansea 003 W02000170 Abertawe 003 Morriston North
#> 4 W06000011 Swansea Swansea 004 W02000171 Abertawe 004 Llangyfelach & Tircoed
#> 5 W06000011 Swansea Swansea 005 W02000172 Abertawe 005 Gorseinon
#> 6 W06000011 Swansea Swansea 006 W02000173 Abertawe 006 Birchgrove
#> 7 W06000011 Swansea Swansea 007 W02000174 Abertawe 007 Loughor
#> 8 W06000011 Swansea Swansea 008 W02000175 Abertawe 008 Morriston South
#> 9 W06000011 Swansea Swansea 009 W02000176 Abertawe 009 Mynydd-bach
#> 10 W06000011 Swansea Swansea 010 W02000177 Abertawe 010 Llansamlet
#> msoa21hclnmw geometry
#> 1 Pontarddulais MULTIPOLYGON (((-4.044836 5...
#> 2 Clydach a Mawr POLYGON ((-3.976283 51.7646...
#> 3 Gogledd Treforys POLYGON ((-3.913253 51.6935...
#> 4 Llangyfelach a Thircoed POLYGON ((-4.011018 51.7080...
#> 5 Gorseinon MULTIPOLYGON (((-4.062941 5...
#> 6 Gellifedw POLYGON ((-3.875069 51.6875...
#> 7 Casllwchwr MULTIPOLYGON (((-4.053356 5...
#> 8 De Treforys POLYGON ((-3.929819 51.6721...
#> 9 Mynydd-bach POLYGON ((-3.933911 51.6730...
#> 10 Llansamlet POLYGON ((-3.898853 51.6750...
bounds("msoa", "lad", "Shepway", lookup_year = 2011, within_year = 2015)
#> Joining with `by = join_by(msoa11nm)`
#> Simple feature collection with 14 features and 5 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 0.7770266 ymin: 50.91095 xmax: 1.221137 ymax: 51.205
#> Geodetic CRS: WGS 84
#> First 10 features:
#> lad15cd lad15nm msoa11nm msoa11cd msoa11hclnm
#> 1 E07000112 Shepway Shepway 001 E02005102 Lyminge, Densole & Elham
#> 2 E07000112 Shepway Shepway 002 E02005103 Hawkinge
#> 3 E07000112 Shepway Shepway 003 E02005104 Folkestone North East
#> 4 E07000112 Shepway Shepway 004 E02005105 Folkestone Foord
#> 5 E07000112 Shepway Shepway 005 E02005106 Cheriton & Horn Street
#> 6 E07000112 Shepway Shepway 006 E02005107 Folkestone Morehall & Sandgate
#> 7 E07000112 Shepway Shepway 008 E02005109 Saltwood, Seabrook & Etchinghill
#> 8 E07000112 Shepway Shepway 009 E02005110 Lympne & Palmarsh
#> 9 E07000112 Shepway Shepway 010 E02005111 Hythe
#> 10 E07000112 Shepway Shepway 011 E02005112 Dymchurch, St Mary's Bay & Brookland
#> geometry
#> 1 POLYGON ((1.089762 51.18973...
#> 2 POLYGON ((1.170835 51.13259...
#> 3 POLYGON ((1.184798 51.09985...
#> 4 POLYGON ((1.189394 51.08954...
#> 5 POLYGON ((1.135277 51.09801...
#> 6 POLYGON ((1.17032 51.0953, ...
#> 7 POLYGON ((1.111727 51.12941...
#> 8 POLYGON ((1.000461 51.1184,...
#> 9 POLYGON ((1.062613 51.07642...
#> 10 POLYGON ((0.9884286 51.0706...
bounds("rgn", country_filter = "EN", resolution = "BUC")
#> Simple feature collection with 9 features and 8 fields
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: -6.419011 ymin: 49.86463 xmax: 1.768937 ymax: 55.81166
#> Geodetic CRS: WGS 84
#> rgn21cd rgn21nm bng_e bng_n long lat
#> 1 E12000007 London 517515 178392 -0.308660 51.49227
#> 2 E12000001 North East 417314 600356 -1.728880 55.29701
#> 3 E12000005 West Midlands 386294 295477 -2.203580 52.55697
#> 4 E12000003 Yorkshire and The Humber 446902 448736 -1.287140 53.93264
#> 5 E12000006 East of England 571078 263235 0.504207 52.24073
#> 6 E12000004 East Midlands 477659 322635 -0.849690 52.79572
#> 7 E12000002 North West 350014 506279 -2.772390 54.44944
#> 8 E12000008 South East 470062 172924 -0.993110 51.45097
#> 9 E12000009 South West 285013 102567 -3.633460 50.81119
#> shape_area shape_length geometry
#> 1 1594697003 256347.9 POLYGON ((-0.0968623 51.690...
#> 2 8675517225 804893.9 MULTIPOLYGON (((-1.540483 5...
#> 3 13003737567 953773.4 POLYGON ((-1.958916 53.2166...
#> 4 15560353265 982047.7 POLYGON ((-0.7829333 54.562...
#> 5 19584692923 1047595.8 MULTIPOLYGON (((1.604498 52...
#> 6 15810723352 1066495.4 POLYGON ((-0.2997642 53.614...
#> 7 14913854032 1066984.7 POLYGON ((-2.675591 55.1733...
#> 8 19399927121 1389475.4 MULTIPOLYGON (((-1.590507 5...
#> 9 24385283189 2378388.7 MULTIPOLYGON (((-6.398846 4...
bounds("parish", "utla", "Isles of Scilly")
#> Simple feature collection with 4 features and 4 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -6.393821 ymin: 49.90298 xmax: -6.244608 ymax: 49.98065
#> Geodetic CRS: WGS 84
#> par22cd par22nm utla22cd utla22nm
#> 1 E04012729 Bryher E06000053 Isles of Scilly
#> 2 E04012731 St Martin's E06000053 Isles of Scilly
#> 3 E04012732 St Mary's E06000053 Isles of Scilly
#> 4 E04012733 Tresco E06000053 Isles of Scilly
#> geometry
#> 1 MULTIPOLYGON (((-6.386119 4...
#> 2 MULTIPOLYGON (((-6.273013 4...
#> 3 MULTIPOLYGON (((-6.280232 4...
#> 4 MULTIPOLYGON (((-6.361791 4...
bounds("spr")
#> Simple feature collection with 8 features and 8 fields
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: -8.649603 ymin: 54.63326 xmax: -0.7546071 ymax: 60.84569
#> Geodetic CRS: WGS 84
#> spr22cd spr22nm bng_e bng_n long lat shape_area
#> 1 S17000013 Mid Scotland and Fife 282520 731011 -3.90787 56.45655 9129823415
#> 2 S17000011 Highlands and Islands 244281 863126 -4.60963 57.63108 40126955263
#> 3 S17000020 Glasgow 264285 664694 -4.16969 55.85627 207721111
#> 4 S17000014 North East Scotland 352284 799608 -2.78889 57.08497 8957071558
#> 5 S17000019 Central Scotland 281356 669376 -3.89920 55.90282 940131195
#> 6 S17000018 West Scotland 239229 655570 -4.56416 55.76667 2288753142
#> 7 S17000015 South Scotland 300085 608202 -3.57755 55.35763 16115290761
#> 8 S17000012 Lothian 316704 666932 -3.33329 55.88829 858325682
#> shape_length geometry
#> 1 612257.00 POLYGON ((-3.894724 56.9227...
#> 2 8790966.43 MULTIPOLYGON (((-5.572362 5...
#> 3 87267.24 POLYGON ((-4.276113 55.9296...
#> 4 561602.62 POLYGON ((-2.847909 57.7061...
#> 5 235997.35 POLYGON ((-3.733132 56.0618...
#> 6 563692.94 MULTIPOLYGON (((-5.07178 55...
#> 7 947497.50 MULTIPOLYGON (((-5.106759 5...
#> 8 193925.75 POLYGON ((-3.425965 55.9938...
bounds("npark", within_names = "Bannau Brycheiniog")
#> Simple feature collection with 1 feature and 9 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -3.989641 ymin: 51.70209 xmax: -2.952097 ymax: 52.07827
#> Geodetic CRS: WGS 84
#> npark22cd npark22nm npark22nmw bng_e bng_n long
#> 1 W18000001 Bannau Brycheiniog Bannau Brycheiniog 298390 221836 -3.47776
#> lat shape_area shape_length geometry
#> 1 51.88579 1350006090 268985.5 POLYGON ((-3.120246 52.0732...