【问题标题】:Problem installing raster package for R 4.2.1 on Ubuntu 20.04在 Ubuntu 20.04 上为 R 4.2.1 安装光栅包时出现问题
【发布时间】:2022-07-12 09:09:56
【问题描述】:

我正在尝试安装光栅包以便能够在 RStudio 中运行模型 - 我正在使用 Ubuntu 20.04 和 R 4.2.1。每当我在 RStudio 控制台中运行install.packages(\'raster\') 时,我都会得到this error。我已经为 Ubuntu 安装了 r-cran-raster,正在使用 PPA,并尝试下载 raster 包以手动安装。

我对 R 和 Ubuntu 比较陌生,所以如果有任何关于尝试的建议,我将不胜感激!

来自install.packages(\'raster\') 的错误消息:

** R
** inst
** byte-compile and prepare package for lazy loading
in method for ‘brick’ with signature ‘x=\"kasc\"’: no definition for class “kasc”
in method for ‘brick’ with signature ‘x=\"grf\"’: no definition for class “grf”
in method for ‘coerce’ with signature ‘\"STFDF\",\"RasterBrick\"’: no definition for class “STFDF”
in method for ‘coerce’ with signature ‘\"STSDF\",\"RasterBrick\"’: no definition for class “STSDF”
in method for ‘coerce’ with signature ‘\"asc\",\"RasterLayer\"’: no definition for class “asc”
in method for ‘coerce’ with signature ‘\"RasterLayer\",\"asc\"’: no definition for class “asc”
in method for ‘coerce’ with signature ‘\"kasc\",\"RasterBrick\"’: no definition for class “kasc”
in method for ‘coerce’ with signature ‘\"kasc\",\"RasterStack\"’: no definition for class “kasc”
in method for ‘coerce’ with signature ‘\"kde\",\"RasterLayer\"’: no definition for class “kde”
in method for ‘coerce’ with signature ‘\"grf\",\"RasterBrick\"’: no definition for class “grf”
in method for ‘coerce’ with signature ‘\"grf\",\"RasterLayer\"’: no definition for class “grf”
in method for ‘extent’ with signature ‘x=\"bbox\"’: no definition for class “bbox”
in method for ‘extent’ with signature ‘x=\"sf\"’: no definition for class “sf”
in method for ‘extract’ with signature ‘x=\"Raster\",y=\"sf\"’: no definition for class “sf”
in method for ‘mask’ with signature ‘x=\"Raster\",mask=\"sf\"’: no definition for class “sf”
in method for ‘raster’ with signature ‘x=\"sf\"’: no definition for class “sf”
in method for ‘raster’ with signature ‘x=\"kasc\"’: no definition for class “kasc”
in method for ‘raster’ with signature ‘x=\"asc\"’: no definition for class “asc”
in method for ‘raster’ with signature ‘x=\"kde\"’: no definition for class “kde”
in method for ‘raster’ with signature ‘x=\"grf\"’: no definition for class “grf”
in method for ‘rasterize’ with signature ‘x=\"sf\",y=\"Raster\"’: no definition for class “sf”
Creating a generic function for ‘rowSums’ from package ‘base’ in package ‘raster’
Creating a generic function for ‘colSums’ from package ‘base’ in package ‘raster’
in method for ‘setValues’ with signature ‘x=\"RasterLayerSparse\"’: no definition for class “RasterLayerSparse”
in method for ‘stack’ with signature ‘x=\"kasc\"’: no definition for class “kasc”
munmap_chunk(): invalid pointer
Aborted (core dumped)
ERROR: lazy loading failed for package ‘raster’
* removing ‘/home/emmsage/R/x86_64-pc-linux-gnu-library/4.2/raster’
Warning in install.packages :
  installation of package ‘raster’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpuqJnA5/downloaded_packages’

    标签: r ubuntu-20.04 r-raster


    【解决方案1】:

    @Zheyuan 的回答非常好、完整和详细,并且很好地利用了现有的 Ubuntu 二进制文件和适当的 PPA。

    但最近,通过我创建的r2u 设置提供了一个新选择。它非常相似,但提供全部CRAN 作为 Ubuntu 20.04 和 22.04 的二进制文件。我自己和其他一些人已经非常广泛地使用它。

    我录制了一个快速动画 gif 以显示 I will post at Twitter 引用此答案(我不能在此处发布超过 2mb 的 gif,因此绕道而行)。我在这里使用 Docker 来模拟一个带有 R 的“空”系统,而在 20.04“焦点”下没有太多其他东西。 r2u 具有您需要在一个简单的脚本中进行的设置步骤,您可以检查并仔细运行它的五个步骤。

    完成后,您将获得install.packages("raster") 给您所有的二进制文件一步。 (在视频中我还告诉了我的电脑服务器的本地地址。这里只需要,一般不需要。)

    【讨论】:

      【解决方案2】:

      包裹光栅取决于大地,对外部库有系统要求。


      在 Ubuntu 20.04 上,执行以下操作。

      安装地球观测系统

      # Add the Ubuntu GIS PPA
      sudo add-apt-repository ppa:ubuntugis/ppa
      
      ## update cache
      sudo apt-get update
      
      # Install the packages
      sudo apt-get install software-properties-common geos
      

      安装GDAL

      sudo apt-get install libpq-dev gdal-bin libgdal-dev
      

      安装项目

      sudo apt-get install proj-bin
      

      安装sqlite3

      sudo apt install sqlite3
      

      只有在这些之后,你才能做到install.packages("raster") inR.

      【讨论】:

        猜你喜欢
        • 2021-01-03
        • 1970-01-01
        • 2021-04-07
        • 2021-08-23
        • 2020-08-02
        • 2021-02-24
        • 2021-08-06
        • 1970-01-01
        • 2021-02-25
        相关资源
        最近更新 更多