My goal is to download an image from a URL and then display it in R.
I found a URL and found out how to download it. But the downloaded file can not be previewed because it is 'damaged, corrupted, or too big'.
y = "http://upload.wikimedia.org/wikipedia/commons/ 5/5D / Aaron Aichhatt 10 TIFF. JPGs" Download.php (y, 'y.jpg' )
I also tried
in the image ('y.jpg'), but shows an error message: Error in image.default ("y.jpg"): Logic matrix should be such as
any suggestions?
If I try your code, it seems that the image has been downloaded. However, when the window image was opened with the viewer, it also says that it is corrupt. The reason for this is that you have not specified the mode
in the download.file
statement.
Try it out:
for more information about the mode? Download.file
view> download.file (y, 'y.jpg', mode = 'wb')
/ code>
At least the file you downloaded is working like this
To see the image in R
jj & lt; - readJPEG ("y.jpg", root = TRUE) plot (0: 1, 0: 1, type = "n", n = falls, axis = FALSE) raster image (jj, 0,0,1,1 )
or or
No comments:
Post a Comment