query_maps {osdatahub} | R Documentation |
Query the OS Maps API
Description
Retrieve pre-rendered tiles from the web maps service of the Maps API in the Ordnance Survey Data Hub.
Usage
query_maps(
x,
layer = c("Road_27700", "Road_3857", "Outdoor_27700", "Outdoor_3857", "Light_27700",
"Light_3857", "Leisure_27700"),
zoom,
output_dir,
overwrite = FALSE,
key = get_os_key(),
...
)
## S3 method for class 'qExtent'
query_maps(
x,
layer = c("Road_27700", "Road_3857", "Outdoor_27700", "Outdoor_3857", "Light_27700",
"Light_3857", "Leisure_27700"),
zoom,
output_dir,
overwrite = FALSE,
key = get_os_key(),
...
)
Arguments
x |
Object defining the query extent. Should be of type |
layer |
(character) The name of the layer to query. See details. |
zoom |
(numeric) The zoom level of the tiles to return. If omitted, a suitable zoom level will be estimated. See details. |
output_dir |
(character) Path to the directory where the downloaded tiles will be saved. |
overwrite |
Boolean. Should existing files be overwritten? Default is
|
key |
(character) OS API key. Default action is to search for an
environment variable using |
... |
Additional parameters (not currently used). |
Details
The OS Maps API serves pre-rendered raster tiles and is available in two projections; British National Grid and Web Mercator. This function provides basic access to download these tiles to your local machine.
Alternatively, you can request the maps using the Open Geospatial Consortium Web Map Tile Service (WMTS) standard or RESTful ZXY for easy access/visualisation in most GIS software and web mapping applications. More information on the Maps API is available from: https://osdatahub.os.uk/docs/wmts/technicalSpecification.
The parameter x
currently only accepts a query extent created from
extent_from_*
family of functions. The coordinate reference system
of this extent must match the coordinate reference system of the returned
tiles (i.e. only EPSG:27700 and EPSG:3857 are accepted).
The available layers are Road, Outdoor, Light in both 27700 and 3857, plus
Leisure in 27700. These should be specified as combined strings to the
layer
argument, e.g. 'Road_27700'.
The zoom levels available vary based on the projection of the tile matrix set. EPSG:3857 is from 7 to 20 and EPSG:27700 is from 0 to 13. See the technical specifications for more information on the scale and resolution: https://osdatahub.os.uk/docs/wmts/technicalSpecification
Value
A list of file paths to the downloaded image tiles, their bounding boxes, and coordinate reference system information.
See Also
Examples
# Define an extent.
OS_ext <- extent_from_bng('SU3715')
# Download tiles.
imgTile <- query_maps(OS_ext,
layer = 'Light_27700',
output_dir = tempdir())
# The tiles can be merged together and georeferenced for spatial applications.