Create a city view showcasing a particular city or region using OpenStreetMap (OSM) data retreived trough the Overpass API. Please note that OpenStreetMap is open data and can be freely utilized for any purpose, as long as proper credit is given to OpenStreetMap and its contributors.

cityview(
  name = NULL,
  zoom = 1,
  theme = c(
    "vintage", "modern", "bright", "delftware", "comic",
    "rouge", "original", "midearth", "batik", "vice"
  ),
  border = c(
    "none", "circle", "rhombus", "square",
    "hexagon", "octagon", "decagon", "bbox"
  ),
  halftone = NULL,
  legend = FALSE,
  places = 0,
  license = TRUE,
  timeout = 25,
  filename = NULL,
  verbose = TRUE,
  bot = FALSE
)

Arguments

name

a character specifying the name of the city as provided by list_cities(), or an object created using new_city(), or a row of the ouput of list_cities(). If NULL (default), chooses a random city.

zoom

a numeric value specifying the amount of zoom. Values > 1 increase zoom and speed up computation time, while values < 1 decrease zoom and increase computation time. For zoom levels below 0.5, the computation time can be very long.

theme

a character specifying the theme of the plot, or a named list specifying a custom theme (see the details section for more information about the composition of this list). Possible pre-specified themes are vintage (default), modern, bright, delftware, comic, rouge, original, midearth, batik and vice.

border

a character specifying the type of border to use. Possible options are none (default), circle, rhombus, square, hexagon (6 vertices), octagon (8 vertices), decagon (10 vertices) and bbox (the bounding box for the entire city, argument zoom will be ignored).

halftone

a character specifying the color of applied halftone dither.

legend

logical. Whether to add a distance measurer and a compass in the bottom left corner of the image.

places

an integer specifying how many suburb, quarter and neighbourhood names to add to the image.

license

logical. Whether to add the OpenStreetMap licence in the bottom right corner of the figure.

timeout

a value specifying the timeout (in seconds) for the Overpass server. It may be necessary to increase this value for large or populated areas because the server may time out before all data are delivered (if this occurs you will receive the following error message: runtime error: Query timed out in "recurse" at line ... after ... seconds.

filename

character. If specified, the function exports the plot at an appropriate size and does not return a ggplot2 object.

verbose

logical. Whether to show a progress bar during execution.

bot

logical. Enable functionality used by the Twitter bot.

Details

The theme argument can take a custom list as input (see the example). This list must contain all of the following elements:

colors

  • background: A single color to be used for the background.

  • water: A single color to be used for the water.

  • landuse: A single color or a vector of multiple colors to be used for the landuse.

  • contours: A single color to be used for the contours (lines) of landuse and buildings.

  • streets: A single color to be used for the streets.

  • rails: A single color or a vector of two colors to be used for the rails.

  • buildings: A single color or a vector of multiple colors to be used for the buildings.

  • text: A single color to be used for the text.

font

  • family: A string specifying the family of the font.

  • face: A string specifying the face of the font.

  • scale: A single value specifying the expansion factor of the characters in the font.

  • append: Optional. A string to append the city name with at both sides.

size

  • borders: A named list containing sizes for the borders contours, water, canal and river.

  • streets: A named list contianing sizes for the streets path, residential, structure, tertiary, secondary, primary, motorway, rails and runway.

Author

Koen Derks, koen-derks@hotmail.com

Examples

if (FALSE) {
# 1. Simple example
# Create a city view of Amsterdam in a circle
cityview(name = "Amsterdam", border = "circle")

# 2. Advanced example
# Custom theme (black, beige and white), streets only, direct export
myTheme <- list(
  colors = list(
    background = "#232323",
    water = NA,
    landuse = NA,
    contours = NA,
    streets = "#d7b174",
    rails = c("#d7b174", "#232323"),
    buildings = NA,
    text = "#ffffff",
    waterlines = NA
  ),
  font = list(
    family = "serif",
    face = "bold",
    scale = 1,
    append = "\u2014"
  ),
  size = list(
    borders = list(
      contours = 0.15,
      water = 0.4,
      canal = 0.5,
      river = 0.6
    ),
    streets = list(
      path = 0.2,
      residential = 0.3,
      structure = 0.35,
      tertiary = 0.4,
      secondary = 0.5,
      primary = 0.6,
      motorway = 0.8,
      rails = 0.75,
      runway = 3
    )
  )
)
cityview(
  name = "Amsterdam", theme = myTheme,
  border = "square", filename = "Amsterdam.png"
)
}