gt_make_raster_from_polygon {googletraffic} | R Documentation |
Make Google Traffic Raster Based on Polygon
Description
Make a raster of Google traffic data, where each pixel has one of four values indicating traffic volume (no traffic, light, moderate, and heavy).
Usage
gt_make_raster_from_polygon(
polygon,
zoom,
google_key,
height_width_max = 2000,
height = NULL,
width = NULL,
traffic_color_dist_thresh = 4.6,
traffic_color_dist_metric = "CIEDE2000",
webshot_zoom = 1,
webshot_delay = NULL,
reduce_hw = 10,
return_list_of_rasters = FALSE,
mask_to_polygon = TRUE,
print_progress = TRUE
)
Arguments
polygon |
Polygon ( |
zoom |
Zoom level; integer from 5 to 20. For more information about how zoom levels correspond to pixel size, see here and here. |
google_key |
Google API key, where the Maps JavaScript API is enabled. To create a Google API key, follow these instructions. |
height_width_max |
Maximum pixel height and width to check using for each API query (pixel length depends on zoom). If the same number of API queries can be made with a smaller height/width, the function will use a smaller height/width. If |
height |
Height, in pixels, for each API query (pixel length depends on zoom). Enter a |
width |
Pixel, in pixels, for each API query (pixel length depends on zoom). Enter a |
traffic_color_dist_thresh |
Google traffic relies on four main base colors: |
traffic_color_dist_metric |
See above; this parameter changes the metric used to calculate distances between colors. By default, |
webshot_zoom |
How many pixels should be created relative to height and width values. If |
webshot_delay |
How long to wait for Google traffic layer to render (in seconds). Larger height/widths require longer delay times. If |
reduce_hw |
Number of pixels to reduce height/width by. Doing so creates some overlap between grids to ensure there is not blank space between tiles. (Default: |
return_list_of_rasters |
Whether to return a list of raster tiles instead of mosaicing together. (Default: |
mask_to_polygon |
Whether to mask raster to |
print_progress |
Show progress for which grid / API query has been processed. (Default: |
Value
Returns a georeferenced raster. Raster pixels can contain the following values: 1 = no traffic; 2 = medium traffic; 3 = high traffic; 4 = heavy traffic.
References
Markus Hilpert, Jenni A. Shearston, Jemaleddin Cole, Steven N. Chillrud, and Micaela E. Martinez. Acquisition and analysis of crowd-sourced traffic data. CoRR, abs/2105.12235, 2021.
Pavel Pokorny. Determining traffic levels in cities using google maps. In 2017 Fourth International Conference on Mathematics and Computers in Sciences and in Industry (MCSI), pages 144–147, 2017.
Examples
## Not run:
## Grab polygon of Manhattan
us_sp <- raster::getData('GADM', country='USA', level=2)
ny_sp <- us_sp[us_sp$NAME_2 %in% "New York",]
## Make raster
r <- gt_make_raster_from_polygon(polygon = ny_sp,
height = 2000,
width = 2000,
zoom = 16,
google_key = "GOOGLE-KEY-HERE")
## End(Not run)