getTargomoPolygons: Add Targomo Polygons to a Leaflet Map

Description Usage Arguments Value Examples

View source: R/polygons.R

Description

Functions for retrieving isochrone polygons from the Targomo API and adding drawing them on a leaflet map.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
getTargomoPolygons(source_data = NULL, source_lat = NULL,
  source_lng = NULL, options = targomoOptions(),
  api_key = Sys.getenv("TARGOMO_API_KEY"),
  region = Sys.getenv("TARGOMO_REGION"), config = list(),
  verbose = FALSE, progress = FALSE, timeout = NULL)

drawTargomoPolygons(map, polygons, drawOptions = polygonDrawOptions(),
  group = NULL, ...)

addTargomoPolygons(map, source_data = NULL, source_lng = NULL,
  source_lat = NULL, options = targomoOptions(),
  drawOptions = polygonDrawOptions(), group = NULL, ...,
  api_key = Sys.getenv("TARGOMO_API_KEY"),
  region = Sys.getenv("TARGOMO_REGION"), config = list(),
  verbose = FALSE, progress = FALSE, timeout = NULL)

Arguments

source_data

The data object from which source ppoints are derived.

source_lng, source_lat

Vectors/one-sided formulas of longitude and latitude.

options

A list of targomoOptions to call the API.

api_key

Your Targomo API key - defaults to the TARGOMO_API_KEY ennvironment variable

region

Your Targomo region - defaults to the TARGOMO_REGION environment variable

config

Config options to pass to httr::POST e.g. proxy settings

verbose

Whether to print out information about the API call.

progress

Whether to show a progress bar of the API call.

timeout

Timeout in seconds (leave NULL for no timeout/curl default).

map

A leaflet map.

polygons

A polygons dataset returned by getTargomoPolygons, for drawing

drawOptions

A list of polygonDrawOptions to determine how to show the resulting polygons on the map.

group

The leaflet map group to add the polygons to. A single group is used for all the polygons added by one API call.

...

Further arguments to pass to addPolygons

Value

For 'get*', an object of class "sf" containing the polygons. For 'draw*' and 'add*', the leaflet map returned with the polygons drawn on.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# load leaflet package
library(leaflet)
l <- leaflet()

# get the polygons
p <- getTargomoPolygons(source_lat = 51.5007, source_lng = -0.1246,
                        options = targomoOptions(travelType = "bike"))

# draw them on the map
l %>% drawTargomoPolygons(polygons = p, group = "BigBenBike")

# note could combine get... and draw... into one with add...

TargomoR documentation built on Dec. 7, 2019, 1:07 a.m.