Makes an entire OSM map for the given bbox using the submitted data, or by
downloading data if none submitted. This is a convenience function enabling
an entire map to be produced according to the graphical format specified with
the structures argument.
Usage
make_osm_map(
bbox,
osm_data,
structures = osm_structures(),
dat_prefix = "dat_"
)Arguments
- bbox
The bounding box for the map. A 2-by-2 matrix of 4 elements with columns of min and max values, and rows of x and y values. If
NULL,bboxis taken from the largest extent of OSM objects inosm_data.- osm_data
A list of OSM objects as returned from
extract_osm_objects. These objects may be included in the plot without downloading. These should all be named with the stateddat_prefixand have suffixes as given instructures.- structures
A
data.framespecifying types of OSM structures as returned fromosm_structures, and potentially modified to alter lists of structures to be plotted, and their associated colours. Objects are overlaid on plot according to the order given instructures.- dat_prefix
Prefix for data structures (default
dat_). Final data structures are created by appending the suffixes fromosm_structures.
Value
List of two components:
List of OSM structures each as
Spatial(Points/Lines/Polygons)DataFrameand appended toosm_data(which isNULLby default), andThe
mapas aggplot2object
Note
If osm_data is not given, then data will be downloaded, which can take
some time. Progress is dumped to screen.
See also
Other construction:
add_osm_objects(),
osm_basemap(),
osm_structures(),
print_osm_map()
Examples
structures <- c ("highway", "park")
structs <- osm_structures (structures = structures, col_scheme = "light")
# make_osm_map returns potentially modified list of data using the provided
# 'london' data for highways and parks.
dat <- make_osm_map (osm_data = london, structures = structs)
#> Warning: In `margin()`, the argument `t` should have length 1, not length 4.
#> ℹ Argument get(s) truncated to length 1.
#> Warning: In `margin()`, the argument `t` should have length 1, not length 4.
#> ℹ Argument get(s) truncated to length 1.
# or download data automatically using a defined bounding boox
bbox <- get_bbox (c (-0.14, 51.51, -0.12, 51.52))
# \donttest{
dat <- make_osm_map (bbox = bbox, structures = structs)
#> Downloading and extracting OSM data for 2 structures ...
#>
|
| | 0%
#> Issuing query to Overpass API ...
#> Announced endpoint: lambert.openstreetmap.de/
#> Query complete!
#> converting OSM data to sf format
#>
|
|=================================== | 50%
#> Issuing query to Overpass API ...
#> Announced endpoint: lambert.openstreetmap.de/
#> Query complete!
#> converting OSM data to sf format
#>
|
|======================================================================| 100%
#> That took 2.641s
#> Warning: In `margin()`, the argument `t` should have length 1, not length 4.
#> ℹ Argument get(s) truncated to length 1.
#> Warning: In `margin()`, the argument `t` should have length 1, not length 4.
#> ℹ Argument get(s) truncated to length 1.
print_osm_map (dat$map)
# }
