A way to access google streetview from R?

邮差的信 提交于 2019-11-29 02:26:00

My googleway package has a google map widget (and also works with Shiny).

You'll need a valid Google API key to use it

library(googleway)

key <- "your_api_key"

df <- data.frame(lat = -37.817714,
                 lon = 144.967260,
                 info = "Flinders Street Station")

google_map(key = key, height = 600, search_box = T) %>%
    add_markers(data = df, info_window = "info")

## other available methods
# add_markers
# add_heatmap
# add_circles
# add_traffic
# add_bicycling
# add_transit

Satellite

Satellite / Street

Street view

(notice the marker is still there)


Update - Static Street view map

There's also a google_streetview() function that will download a static streetview image (using the Google Street View Static Image API)

google_streetview(location = c(-37.8177, 144.967),
                  size = c(400,400),
                  panorama_id = NULL,
                  output = "plot",
                  heading = 90,
                  fov = 90,
                  pitch = 0,
                  response_check = FALSE,
                  key = key)

There's not current an R package that does this, however I can offer you 2 hacks to get the job done.

  1. Use rvest, other scraping packages, or even simply download.file with one of the many independent websites that provide different interfaces/views of streetview data.

    That way you can just parameterize the URI and download the target image.

  2. Use V8 (possibly leveraging browserify) to run the npm package extract-streetview.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!