Title: | Retrieve Area Boundaries and Data from the ONS Open Geography Portal |
---|---|
Description: | The main purpose of this package is to download area lookups and boundaries (in GeoJSON format) using the ONS Open Geography API, for all areas at a specified level within a specified area. |
Authors: | Francis Barton [aut, cre] |
Maintainer: | Francis Barton <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.99 |
Built: | 2024-11-18 02:53:21 UTC |
Source: | https://codeberg.org/francisbarton/boundr |
If you have a tibble such as those produced by lookup()
- that is, there is
a column of geographical ONS codes ending in 'cd' - simply use this table as
the basis for retrieving the relevant boundaries or centroids.
add_geometry_to_table()
will use the lefthand-most column ending with
"cd".
add_geometry_to_table( tbl, opts = boundr_options(), geometry = c("boundaries", "centroids") ) add_geometry( tbl, opts = boundr_options(), geometry = c("boundaries", "centroids") )
add_geometry_to_table( tbl, opts = boundr_options(), geometry = c("boundaries", "centroids") ) add_geometry( tbl, opts = boundr_options(), geometry = c("boundaries", "centroids") )
tbl |
A tibble with a column containing ONS geographical codes. |
opts |
Should be set with the |
geometry |
character. Two options: "boundaries" (the default) and
"centroids". By default, |
If successful, will return the initial table with an additional geometry column added. Duplicate rows will be removed.
tibble::tibble(wd23cd = c("S13003001", "N08000520", "W05001522")) |> add_geometry_to_table()
tibble::tibble(wd23cd = c("S13003001", "N08000520", "W05001522")) |> add_geometry_to_table()
bounds()
opts()
is an alias for this function.
boundr_options( resolution = res_codes(), return_width = c("tidy", "full", "minimal"), crs = 4326, query_option = NULL ) opts( resolution = res_codes(), return_width = c("tidy", "full", "minimal"), crs = 4326, query_option = NULL )
boundr_options( resolution = res_codes(), return_width = c("tidy", "full", "minimal"), crs = 4326, query_option = NULL ) opts( resolution = res_codes(), return_width = c("tidy", "full", "minimal"), crs = 4326, query_option = NULL )
resolution |
character. See |
return_width |
character. How many of the possible columns in the
returned table to keep. Options are "tidy", "full" or "minimal". "Tidy" aims
to return four data columns (usually) - two columns for the lookup level
codes and names, and two for the within level codes and names. Plus a
geometry column. "Full" aims to return all data columns from the lookup.
"Minimal" aims to return just the two (usually!) data columns relating to
|
crs |
The Coordinate Reference System (CRS) code to use |
query_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 function again with a different option from the list. |
boundr_options(crs = 27700) # Set the CRS to British National Grid boundr_options(return_width = "full") # Ask boundr to return all data columns
boundr_options(crs = 27700) # Set the CRS to British National Grid boundr_options(return_width = "full") # Ask boundr to return all data columns
Return boundary data at a specified level and area from the ONS OG API
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") )
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") )
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 |
within_names , within_codes
|
character. In order to restrict data
returned to a specific area, either |
lookup_year |
numeric or character. A specific year for data relating
to |
within_year |
numeric or character. A specific year for data relating
to |
opts |
Should be set with the |
geometry |
character. Two options: "boundaries" (the default) and
"centroids". By default, |
an sfc
tibble (data frame with geometry)
boundr_options
bounds("msoa", "lad", "Swansea") bounds("wd", "lad", "Shepway", within_year = 2016) # Shepway no longer exists bounds("rgn", opts = boundr_options(resolution = "BUC")) bounds("par", "lad", "Isles of Scilly") # par = "parish" bounds("spr") bounds("npark", within_names = "Bannau Brycheiniog") bounds("msoa", "utla", "Swindon", geometry = "centroids")
bounds("msoa", "lad", "Swansea") bounds("wd", "lad", "Shepway", within_year = 2016) # Shepway no longer exists bounds("rgn", opts = boundr_options(resolution = "BUC")) bounds("par", "lad", "Isles of Scilly") # par = "parish" bounds("spr") bounds("npark", within_names = "Bannau Brycheiniog") bounds("msoa", "utla", "Swindon", geometry = "centroids")
Create a lookup table by querying the ONS OpenGeography API
lookup( lookup_level, within_level = NULL, within_names = NULL, within_codes = NULL, lookup_year = NULL, within_year = NULL, opts = boundr_options() )
lookup( lookup_level, within_level = NULL, within_names = NULL, within_codes = NULL, lookup_year = NULL, within_year = NULL, opts = boundr_options() )
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 |
within_names , within_codes
|
character. In order to restrict data
returned to a specific area, either |
lookup_year |
numeric or character. A specific year for data relating
to |
within_year |
numeric or character. A specific year for data relating
to |
opts |
Should be set with the |
A tibble
lookup("msoa", "lad", "Swindon") lookup("wd", "sener", opts = opts(return_width = "full"))
lookup("msoa", "lad", "Swindon") lookup("wd", "sener", opts = opts(return_width = "full"))
A list of all available resolutions for boundary geometries in the current OpenGeography schema. Not all resolutions are available for all area types! The most common ones are listed first, with the "generalised" (20m resolution) BGC being the preferred option if you don't specify one.
res_codes()
res_codes()