如何在R中保存为谷歌街景API的图像响应?

如何在R中保存为谷歌街景API的图像响应?,r,google-street-view,googleway,R,Google Street View,Googleway,我需要将google_streetview API的结果保存为图像(.jpg,.png) 我正在一个小项目中测试一种图像识别算法。我正在从google street下载一些图像,我需要将这些图像保存为.jpg或.png格式 library(googleway) p <- google_streetview(location = c(centerlat,centerlng), size = c(500,500),

我需要将google_streetview API的结果保存为图像(.jpg,.png)

我正在一个小项目中测试一种图像识别算法。我正在从google street下载一些图像,我需要将这些图像保存为.jpg或.png格式

 library(googleway)

 p <- google_streetview(location = c(centerlat,centerlng),              
              size = c(500,500),                
              panorama_id = NULL,               
              output = "plot",              
              heading = 0,              
              fov = 15,             
              pitch = 0,                
              response_check = FALSE,               
              key = key)
if(stringr::str_count(imagePath,“http”)>0{: 参数的长度为零

第二:

 library(imager)
 imager::save.image(p,"test.jpeg")
imager::save.image(p,“test.jpeg”)中出错: 第一个参数应该是图像


如何自动保存这些图像?

这是一个猜测,因为我没有API密钥

这是谷歌街景功能的最后一点:

map_url <- constructURL(map_url, c(location = location, pano = panorama_id, 
    size = size, heading = heading, fov = fov, pitch = pitch, 
    key = key))
if (output == "plot") {
    z <- tempfile()
    utils::download.file(map_url, z, mode = "wb")
    pic <- jpeg::readJPEG(z)
    file.remove(z)
    graphics::plot(0:1, 0:1, type = "n", ann = FALSE, axes = FALSE)
    return(graphics::rasterImage(pic, 0, 0, 1, 1))
}
else {
    return(map_url)
}

您曾尝试使用
output=“plot”
执行此操作,在这种情况下,它返回
返回值(graphics::rasterImage(pic,0,0,1,1))
,该值始终为空值。

这是一个猜测,因为我没有API键

这是谷歌街景功能的最后一点:

map_url <- constructURL(map_url, c(location = location, pano = panorama_id, 
    size = size, heading = heading, fov = fov, pitch = pitch, 
    key = key))
if (output == "plot") {
    z <- tempfile()
    utils::download.file(map_url, z, mode = "wb")
    pic <- jpeg::readJPEG(z)
    file.remove(z)
    graphics::plot(0:1, 0:1, type = "n", ann = FALSE, axes = FALSE)
    return(graphics::rasterImage(pic, 0, 0, 1, 1))
}
else {
    return(map_url)
}

您曾尝试使用
output=“plot”
执行此操作,在这种情况下,它返回
return(graphics::rasterImage(pic,0,0,1,1))
,它始终是一个空值。

很高兴您看到了答案;我忘记了
output
参数……很高兴您看到答案;我忘记了
output
参数。。。
url = google_streetview(..., output="html")
t = tempfile()
download.file(url, t, model="wb")
message(t, " should be a JPEG...")