geo_get | R Documentation |
The ONS OpenGeography Portal (https://geoportal.statistics.gov.uk/) is a great resource for area boundary and data lookups within the UK. This program focuses on areas within England and Wales only, initially.
geo_get( bounds_level, within, within_level = NULL, bounds_cd = FALSE, within_cd = FALSE, include_msoa = NULL, return_style = "tidy", include_welsh_names = NULL, return_boundaries = TRUE, return_centroids = FALSE, centroid_fields = FALSE, shape_fields = FALSE, spatial_ref = 4326, quiet_read = TRUE )
bounds_level |
The lowest level at which to return codes and names, eg "LSOA". Has to be one of "lsoa", "msoa", "wd/ward", "lad", "cty/county". Case-insensitive. |
within |
The name of a geographic area to filter by eg "Swindon", "Gloucestershire", "Wales", or a set of area codes (with bounds_cd or within_cd). |
within_level |
Upper geographic level to filter at. eg if filtering to
find all LSOAs in a local authority, |
bounds_cd |
When you just supply a list of area codes for places you want boundaries for. NB this relates to lower areas, "bounds" level. |
within_cd |
Usually you'll build the query with a place name to search within. But sometimes you may wish to pass in a vector of area codes instead (if that's all you have, or more likely if you are querying within wards, which don't have unique names (there's a lot of Abbey wards in England!)). If you're passing in area codes not names, set this to TRUE. NB this only applies to the higher, "within", level. |
include_msoa |
If |
return_style |
"tidy" (the default) means all available columns between
|
include_welsh_names |
Only makes a difference when |
return_boundaries |
whether to retrieve object boundaries data from
the API. Default |
return_centroids |
whether to retrieve area centroids instead of
boundaries. Default |
centroid_fields |
Boolean, default FALSE. Whether to include BNG eastings, northings, lat and long fields in the return. NB this doesn't apply to direct (population-weighted) centroid queries. |
shape_fields |
Boolean, default FALSE. Whether to include Shape__Area and Shape__Length fields in the return when returning boundaries. |
spatial_ref |
The (EPSG) spatial reference of any returned geometry. Default value: 4326 ("WGS 84"). This parameter is ignored peacefully if no geometry is returned/returnable, eg lookup queries |
quiet_read |
Controls quiet parameter to sf::st_read |
I want a better name for this function! Suggestions welcome...
a data frame or an sf (simple features) object (data frame with geometries)
geo_get("wd", "Swindon", "lad") geo_get("msoa", "Swansea", "lad", return_centroids = TRUE) %>% head(10) geo_get("lsoa", "Zetland", "ward", shape_fields = TRUE) geo_get(bounds_level = "lad", within = "Gloucestershire", within_level = "cty", return_style = "simple", return_boundaries = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.