gt_load_png_as_traffic_raster {googletraffic} | R Documentation |
Converts PNG to raster
Description
Converts PNG of Google traffic data to raster and translates color values to traffic values
Usage
gt_load_png_as_traffic_raster(
filename,
location,
height,
width,
zoom,
traffic_color_dist_thresh = 4.6,
traffic_color_dist_metric = "CIEDE2000"
)
Arguments
filename |
Filename of PNG file |
location |
Vector of latitude and longitude used to create PNG file using |
height |
Height (in pixels; pixel length depends on zoom) used to create PNG file using |
width |
Width (in pixels; pixel length depends on zoom) used to create PNG file using |
zoom |
Zoom level used to create PNG file using |
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, |
Value
Returns a raster where each pixel represents traffic level (1 = no traffic, 2 = medium traffic, 3 = traffic delays, 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:
## Make png
gt_make_png(location = c(40.712778, -74.006111),
height = 1000,
width = 1000,
zoom = 16,
out_filename = "google_traffic.png",
google_key = "GOOGLE-KEY-HERE")
## Load png as traffic raster
r <- gt_load_png_as_traffic_raster(filename = "google_traffic.png",
location = c(40.712778, -74.006111),
height = 1000,
width = 1000,
zoom = 16)
## End(Not run)