1

I'm attempting to use R within QGIS2.6 on OSX Mavericks but cannot get R to run because rgdal is not available as binary for R3.1.2 (see QGIS log output from R execution console below).

I have installed rgdal on my system R installation using an alternative to install.package but QGIS doesn't seem to be seeing this. Does QGIS use an different R/rgdal location to my main system versions?

R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin13.4.0 (64-bit)

...some packages downloaded here...

The downloaded binary packages are in /var/folders/q4/r2k75kq956l54c4xtcxkscl40000gn/T//RtmpOSE4WR/downloaded_packages tryCatch(find.package("spatstat"), error=function(e) install.packages("spatstat", dependencies=TRUE)) [1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/spatstat" tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE)) package 'rgdal' is available as a source package but not as a binary Warning message: package 'rgdal' is not available (for R version 3.1.2) tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE)) [1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/raster" library("raster") Loading required package: sp library("rgdal") Error in library("rgdal") : there is no package called 'rgdal' Execution halted

added whole error log output January 7, 2015 23:07:23 R execution console output

R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin13.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

options("repos"="http://cran.at.r-project.org/") tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE))

package 'rgdal' is available as a source package but not as a binary

Warning message: package 'rgdal' is not available (for R version 3.1.2) tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE)) [1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/raster" library("raster") Loading required package: sp library("rgdal") Error in library("rgdal") : there is no package called 'rgdal' Execution halted

6
  • hi @Pascal. But I have installed rgdal on my machine R installation.
    – Mark Ruddy
    Jan 5, 2015 at 8:03
  • When you say 'on your system' do you mean within QGIS or from my machine R installation? rgdal has been part of my machine R install and I have been using it successfully. Does QGIS run an independent version of R that is bundled with it? Or does QGIS rely on the machine install?
    – Mark Ruddy
    Jan 5, 2015 at 16:44
  • @MarkRuddy, could you edit your question and paste the actual error lines from the R script output (from QGIS Processing) when you run it?
    – Simbamangu
    Jan 6, 2015 at 5:53
  • @Simbamangu I did include the majority of it in the original question but will add the whole log output.
    – Mark Ruddy
    Jan 7, 2015 at 23:06
  • @Pascal yes I know it says that in QGIS, but I have already installed rgdal. I'm running rgdal in RStudio at the moment. But rgdal is not available as a binary for R 3.1.2. I can install rgdal from source but the QGIS error (above) looks like QGIS is trying to get rgdal as a repos from cran - which can't work... So question is how to get around this when I know rgdal is already on my machine.
    – Mark Ruddy
    Jan 7, 2015 at 23:11

4 Answers 4

1

Here, see if this works:

# This sets the correct dependencies on CRAN
setRepositories(ind = c(1,6))  

# Then install package as usual. 
install.packages('rgdal')
6
  • Hi. Thanks for posting. My rgdal is working from an R session outside of QGIS (say from RStudio). It's only when I try and call R from QGIS tools. Is the code you posted intended to somehow make QGIS 'see' rdgal? MR
    – Mark Ruddy
    Feb 8, 2015 at 19:14
  • From the errors it is looking like rgdal is not loading in the R namespace correctly. I am thinking that a more standard install of rgdal will mitigate the issue. Did you try reinstalling the package using the above method? Install the package in R and not RStudio, which often does not play well with the spatial packages. Feb 8, 2015 at 22:06
  • ok. Used above rgdal install method in R. R tools in QGIS processing toolbox still not able to get rgdal. Log: Warning message: package 'rgdal' is not available (for R version 3.1.2) tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE)) [1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/raster" library("raster") Loading required package: sp library("rgdal") Error in library("rgdal") : there is no package called 'rgdal' Execution halted
    – Mark Ruddy
    Feb 9, 2015 at 8:58
  • This is an odd one. Are you trying to write an R script to run in QGIS or using a preexisting script? Feb 9, 2015 at 14:10
  • Trying the existing scripts contained within the toolbox
    – Mark Ruddy
    Feb 9, 2015 at 17:45
0

The regular RGDAL from the R package repository has had issues in the past - you can use the one provided by kynchaos.com:

  1. Download the DMG from the Frameworks page.
  2. Mount the DMG.
  3. In R, install the package from the included .tgz file: install.packages("/Volumes/rgdal/rgdal_0.9-1.tgz", repos = NULL) (substitute /Volumes/rgdal/ for another package if it's renamed or somehow different to the default).
1
  • Installed rgdal from KyngChaos as instructed but R still not functioning within QGIS. Returning the same rgdal error as in my initial post. Attempted restart of QGIS too.
    – Mark Ruddy
    Jan 5, 2015 at 14:15
0

The issue is that R installations are write-protected by default. Install R into another folder such as C:\R\R-3.1.3 and the problem goes away when you set it as the R path in QGIS. The solution is described here: http://wiki.awf.forst.uni-goettingen.de/wiki/index.php/R_installation

This worked running QGIS 2.8.1 Wien on Windows 7 64-bit. I imagine it will resolve the issue on OS X too.

0

in the "R user library folder" change the location to where your R packages are stored.

In my case "C:\Users\Kuria\Documents\R\win-library\3.5"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.