Learn R Programming

osmplotr (version 0.2.0)

make_osm_map: make_osm_map

Description

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, bbox is taken from the largest extent of OSM objects in osm_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 stated 'dat_prefix' and have suffixes as given in 'structures'.
structures
A data.frame specifying types of OSM structures as returned from osm_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 in 'structures'
dat_prefix
Prefix for data structures (default 'dat_'). Final data structures are created by appending the suffixes from osm_structures().

Value

  • List of two components: (i) List of OSM structures each as Spatial(Polygon/List)DataFrame and appended to `osm_data` (which is NULL by default), and (ii) The map as a ggplot2 object

Note

If 'osm_data' is not given, then data will be downloaded, which can take some time. Progress is dumped to screen.

See Also

plot_osm_basemap, add_osm_objects.

Examples

Run this code
structures <- c ('highway', 'park', 'grass')
structs <- osm_structures (structures=structures, col_scheme='light')
# make_osm_map returns potentially modified list of data using the provided
# 'london' data:
dat <- make_osm_map (osm_data=london, structures=structs)
# or download data automatically using a defined bounding boox
bbox <- get_bbox (c(-0.15,51.5,-0.10,51.52))
dat <- make_osm_map (bbox=bbox, structures=structs)
print (dat$map)

Run the code above in your browser using DataLab