1

I'm trying to download an ascii raster and unzip it using R:

require(raster)
temp <- tempfile()
download.file("http://goo.gl/yGC4GU",temp)
myRaster <- raster( unz(temp, "koppen_ascii.txt") )

but I get the following error message:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘raster’ for signature ‘"unz"’

Is there any alternative method?

Claudia
  • 996
  • 1
  • 10
  • 27
  • 1
    Separate the unzipping from the reading. raster needs a file name, not the output of unz – mdsumner Jun 25 '14 at 11:23
  • Maybe you can find useful hints even in [gis.stackexchange.com](http://gis.stackexchange.com/questions/tagged/r+raster) – Hastur Jun 25 '14 at 12:06

1 Answers1

1

Unzip your file to the working folder and then read it:

> unzip(temp)
> myRaster = raster("./koppen_ascii.txt")

use tempdir() to create a temp directory and pass it as the exdir option to unzip if you want to save it elsewhere.

> zipd = tempdir()
> unzip(temp, exdir=zipd)
> myRaster = raster(file.path(zipd,"koppen_ascii.txt"))
Spacedman
  • 92,590
  • 12
  • 140
  • 224