Skip to contents
library(streetlightR)
library(sf)
library(dplyr)

your_email <- "you@email.com"

Create and upload an example polygon

example_polygon <- sf::st_sfc(
  sf::st_point(cbind(-93.09, 44.95)),
  crs = 4326
) %>%
  sf::st_buffer(500)

name <- paste0("example_polygon_", Sys.time())

upload_zone_set(
  login_email = your_email,
  geom_type = "polygon",
  zones = example_polygon,
  zone_set_name = name
)

Create a streetlight analysis

create_streetlight_analysis(
  login_email = your_email,
  analysis_type = "Zone_Activity_Analysis",
  analysis_name = "{your_name}",
  travel_mode_type = "All_Vehicles",
  output_type = "Volume",
  origin_zone_set = name,
  date_ranges = list(
    start_date = "05/01/2021",
    end_date = "08/31/2021"
  ),
  tags = list("streetlightR"),
  traveler_attributes = FALSE,
  trip_attributes = FALSE
)

Check status and download results

check_analysis_status(
  analysis_name = name,
)

results <- get_analysis_data(
  analysis_name = name,
  metric = "za_all"
)

results