【问题标题】:R - How to download ascii raster and unzip it?R - 如何下载 ascii 光栅并解压缩?
【发布时间】:2014-06-25 11:04:17
【问题描述】:

我正在尝试下载 ascii 栅格并使用 R 解压缩:

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

但我收到以下错误消息:

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

还有其他方法吗?

【问题讨论】:

  • 把解压和阅读分开。 raster 需要一个文件名,而不是 unz 的输出
  • 也许你甚至可以在gis.stackexchange.com中找到有用的提示

标签: r ascii raster


【解决方案1】:

将文件解压缩到工作文件夹,然后阅读:

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

使用tempdir() 创建一个临时目录并将其作为exdir 选项传递给unzip,如果您想将其保存在其他位置。

> zipd = tempdir()
> unzip(temp, exdir=zipd)
> myRaster = raster(file.path(zipd,"koppen_ascii.txt"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-26
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 2015-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多