Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A way to access google streetview from R?

There is a very nice interface to google earth images available via ggmap. For example:

ggmap::get_map(location = c(lon = -95.3632715, lat = 29.7632836), 
               maptype ="satellite",zoom=20)

will return a satellite map image from Google Maps/Earth. On Google Maps website if you zoom a bit more, it switches to streetview. Is there a similar way from R to get the streetview images?

There does seem to be an API, but can't find anything analogous to the ggmap interface in R.

like image 844
Will Cornwell Avatar asked Aug 29 '16 00:08

Will Cornwell


1 Answers

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

enter image description here

Satellite / Street

enter image description here

Street view

(notice the marker is still there)

enter image description here


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)

enter image description here

like image 195
SymbolixAU Avatar answered Nov 20 '22 20:11

SymbolixAU