0

I am using the code below

library(httr)
img<-GET("https://api.weather.com/v3/TileServer/tile/radarFcst? 
ts=1428948600&fts=1428949000&xyz=0:0:1&apiKey=yourApiKey")

How can I display this output I am getting from the API in R? I get output below

class(img)
[1] "response"
> img
Response [https://api.weather.com/v3/TileServer/tile/radarFcst? 
ts=1428948600&fts=1428949000&xyz=0:0:1&apiKey=yourkey]
Date: 2018-07-19 23:16
Status: 400
Content-Type: image/png
Size: 139 B
<BINARY BODY>
Alli
  • 59
  • 3
  • 9
  • What is `GET`? It isn't base R. Please give a [mcve], with necessary packages clearly indicated. – John Coleman Jul 19 '18 at 19:16
  • 1
    Also, [this question](https://stackoverflow.com/q/29110903/4996248) might help. – John Coleman Jul 19 '18 at 19:22
  • What is returned to the console when you run `class(img)`? Is it a `raster` object? You can always try `plot(img)` and see what happens. – JMT2080AD Jul 19 '18 at 23:04
  • @JMT2080AD -I have modified my question. Looks like the GET method is not receiving data? – Alli Jul 19 '18 at 23:28
  • What does the file look like when written to disk using the following: `bin <- content(img, "raw"); writeBin(bin, "myimg.png")` – JMT2080AD Jul 19 '18 at 23:32
  • @JMT2080AD-Error in writeBin(img, "myimg.png") : can only write vector objects – Alli Jul 19 '18 at 23:37
  • Sorry, I updated my comment. I am referencing this -> https://cran.r-project.org/web/packages/httr/vignettes/quickstart.html – JMT2080AD Jul 19 '18 at 23:37
  • I get the same error as before since I am seeing status 400 in the original output I am thinking there was a bad response from the server? – Alli Jul 19 '18 at 23:47

0 Answers0