More trouble Installing rgdal on ubuntu 16.04 - r

This problem installing rgdal is not resolved in other similar questions already posted. I installed gdal using the advice on http://www.sarasafavi.com/installing-gdalogr-on-ubuntu.html and also decribed in other answers like this trouble in installing rgdal on ubuntu 16.04 that means from ppa:ubuntugis.
Then when I try to install rgdal the following error appears
> install.packages("rgdal")
Installing package into ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rgdal_1.3-4.tar.gz'
Content type 'application/x-gzip' length 1664774 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.3-4
checking for /usr/bin/svnversion... no
configure: svn revision: 766
checking for gdal-config... /home/leonardo/anaconda3/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.2
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... no
checking gdal: linking with --libs and --dep-libs... no
/usr/bin/x86_64-linux-gnu-ld: warning: libproj.so.12, needed by /home/leonardo/anaconda3/lib/libgdal.so, not found (try using -rpath or -rpath-link)
/usr/bin/x86_64-linux-gnu-ld: warning: libpoppler.so.71, needed by /home/leonardo/anaconda3/lib/libgdal.so, not found (try using -rpath or -rpath-link)
/usr/bin/x86_64-linux-gnu-ld: warning: libxerces-c-3.2.so, needed by /home/leonardo/anaconda3/lib/libgdal.so,
...
500 lines more
...
/home/leonardo/anaconda3/lib/libgeos_c.so: undefined reference to `geos::geom::PrecisionModel::PrecisionModel(double)'
collect2: error: ld returned 1 exit status
configure: Install failure: compilation and/or linkage problems.
configure: error: GDALAllRegister not found in libgdal.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.5/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
It seems to be a problem with python anaconda that I have previously installed, I removed the anaconda python gdal package using
conda remove gdal
But the problems persist

The only way to solve this was to completely remove anaconda installation, following the instructions on https://conda.io/docs/user-guide/install/linux.html#uninstalling-anaconda-or-miniconda with some minor modifications for ubuntu 16.04, you have to open a terminal and remove the anaconda install directory:
rm -rf ~/anaconda3
rm -rf ~/.condarc ~/.conda ~/.continuum
Edit ~/.bashrc to remove the anaconda directory from your PATH environment variable.
After that the installation of rgdal
install.packages("rgdal")
goes without problems.

Related

How to download Sf package on MacOS

I tried a couple of hours to install sf package (on MacOs) by using most of the solutions I encountered on the web but still, it did not work. Let me show, what I did and then what the problem is step by step.
First, I tried the normal thing install.packages("sf") which resulted in the following error.
URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-2.tgz' deneniyor
Content type 'application/x-gzip' length 93022013 bytes (88.7 MB)
====================================
downloaded 65.3 MB
Warning in install.packages :
downloaded length 68510897 != reported length 93022013
Warning in install.packages :
URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-2.tgz': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-2.tgz' failed
Warning in install.packages :
download of package ‘sf’ failed
Following that, I tried to comply with the instructions in this website https://github.com/r-spatial/sf. To this end, I first installed home brew and then rendered these two codes on the MacOS terminal.
brew install pkg-config
brew install gdal
And, finally, in line with the website's suggestion, I run this code to install rgdal package to get sf installed.
install.packages("rgdal", configure.args = c("--with-proj-lib=/usr/local/lib/", "--with-proj-include=/usr/local/include/"))
However, it came with the following error.
There is a binary version available but the source version is later:
binary source needs_compilation
rgdal 1.5-26 1.5-27 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘rgdal’
URL 'https://cran.rstudio.com/src/contrib/rgdal_1.5-27.tar.gz' deneniyor
Content type 'application/x-gzip' length 4391149 bytes (4.2 MB)
==================================================
downloaded 4.2 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /Library/Frameworks/R.framework/Resources
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
configure: CFLAGS: -Wall -g -O2
configure: CPPFLAGS: -I/usr/local/include
configure: CXXFLAGS: -Wall -g -O2
configure: LDFLAGS: -L/usr/local/lib
configure: LDFLAGS: -L/usr/local/lib
configure: CXX11 is: clang++ -mmacosx-version-min=10.13, CXX11STD is: -std=gnu++11
configure: CXX is: clang++ -mmacosx-version-min=10.13 -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-27
checking for /usr/bin/svnversion... no
configure: svn revision: 1148
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/tc/g15hmz9s0hg1nxmh7_4mw9lm0000gn/T/RtmplfPV9h/downloaded_packages’
As suggested in this website https://github.com/r-spatial/sf, I alternatively tried the solutions in https://github.com/r-spatial/sf/issues/1536#issuecomment-727342736.
Yet, in the part 2, when I run this code chunk,
install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
library(devtools)
install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")
A similar problem emerged for all these codes. For instance, for the first one, the error was;
URL 'http://R-Forge.R-project.org/src/contrib/rgeos_0.5-8.tar.gz' deneniyor
Content type 'application/x-gzip' length 276303 bytes (269 KB)
==================================================
downloaded 269 KB
* installing *source* package ‘rgeos’ ...
** using staged installation
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
configure: rgeos: 0.5-7
checking for /usr/bin/svnversion... no
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision:
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgeos’
Warning in install.packages :
installation of package ‘rgeos’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/tc/g15hmz9s0hg1nxmh7_4mw9lm0000gn/T/RtmplfPV9h/downloaded_packages’
And lastly, I followed the instructions to solve this problem on this website; trouble installing "sf" due to "gdal"
First: gdalinfo --version code resulted in GDAL 3.3.2, released 2021/09/01
Second, I did brew unlink gdal, yet when I run brew link --force gdal2, it did not work. (I am a new user so I assumed it might be because of different versions but when I tried brew link --force gdal3.3.2, it gave me the error Error: No such keg: /opt/homebrew/Cellar/gdal3.3.2.
So, if you can help me how to install sf on MacOS, I will be very glad for that.
The error message lines "Warning in install.packages : downloaded length 68510897 != reported length 93022013" and "Timeout of 60 seconds was reached" suggests the package didn't download properly - this can occur when it takes longer than 60 seconds to download the package to your computer for installation i.e. the "timeout" of 60 seconds is reached.
One solution (the solution that worked in this case) is to increase the amount of time R will wait to download the package by running options(timeout = 1200) before running install.packages("sf")
If you need to build packages from source (with or without openMP) on an M1 mac, I believe the instructions posted here work: https://stackoverflow.com/a/68275558/12957340
Not sure if this is helpful, but I was having similar trouble getting this installed on a fresh Mac. I ended up installing XQuartz (which I didn't have), downloading homebrew to get PROJ, and then reinstalling R (50/50 as to whether I downloaded the right version for my M1 Mac) and got everything installed properly.

Installing the R-package "rgeos" on linux: geos-config not found or not executable

I am running R 3.4.1 on gentoo.
When i try to install the 'rgeos' package, i get this:
> install.packages("rgeos")
Installing package into ‘/home/jody/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://stat.ethz.ch/CRAN/src/contrib/rgeos_0.4-2.tar.gz'
Content type 'application/x-gzip' length 255244 bytes (249 KB)
==================================================
downloaded 249 KB
* installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: x86_64-pc-linux-gnu-gcc
configure: CXX: x86_64-pc-linux-gnu-g++
configure: rgeos: 0.4-2
checking for /usr/bin/svnversion... yes
configure: svn revision: 581
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/jody/R/x86_64-pc-linux-gnu-library/3.4/rgeos’
The downloaded source packages are in
‘/tmp/RtmppEeDps/downloaded_packages’
Warning message:
In install.packages("rgeos") :
installation of package ‘rgeos’ had non-zero exit status
(The same happens if i try to install rgeos on gentoo with R 3.5.1, and also on Centos 7.5 with R 3.5.1.)
While there is a rgeos/configure which is executable in the tar file mentioned above, there is indeed no geos-config in there.
How can i get the rgeos package installed?
Is there perhaps a binary version which i could download?
For Ubuntu (19.10 and likely onward) use:
sudo apt install libgeos-dev
I found the solution.
The "rgeos" package depends on libraries you have to install before running R.
In gentoo i had to do:
sudo emerge --ask sci-libs/geos
In CentOS:
sudo yum install geos geos-devel
After installing these libraries i started R and could install the 'rgeos' package without problems
For Ubuntu 20.04, the solution is:
sudo apt install libgeos-dev
For Arch/Manjaro:
sudo pacman -S geos

Cannot install rgl package

I am running RStudio on Digital Ocean. I want to install a package called rgl. The goal is to install this package without using sudo code. I also tried installing the dependency package 'magick' but no luck. Anyone try this in the past?
I also cannot download xquartz since this in running on digital ocean. That has been an answer I've been researching in order to solve this.
This is the error:
install.packages("rgl", dependencies = TRUE)
Installing package into ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘magick’
trying URL 'https://cran.rstudio.com/src/contrib/magick_2.0.tar.gz'
Content type 'application/x-gzip' length 4998781 bytes (4.8 MB)
==================================================
downloaded 4.8 MB
trying URL 'https://cran.rstudio.com/src/contrib/rgl_0.99.16.tar.gz'
Content type 'application/x-gzip' length 3058794 bytes (2.9 MB)
==================================================
downloaded 2.9 MB
* installing *source* package ‘magick’ ...
** package ‘magick’ successfully unpacked and MD5 sums checked
Package Magick++ was not found in the pkg-config search path.
Perhaps you should add the directory containing `Magick++.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Magick++' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lMagick++-6.Q16
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because Magick++ was not found. Try installing:
- deb: 'libmagick++-dev' (Debian, Ubuntu)
- rpm: 'ImageMagick-c++-devel' (Fedora, CentOS, RHEL)
- csw: 'imagemagick_dev' (Solaris)
On MacOS it is recommended to use install ImageMagick-6 from homebrew
with extra support for fontconfig and rsvg rendering:
brew reinstall imagemagick#6 --with-fontconfig --with-librsvg
For older Ubuntu versions Trusty (14.04) and Xenial (16.04) use our PPA:
sudo add-apt-repository -y ppa:opencpu/imagemagick
sudo apt-get update
sudo apt-get install -y libmagick++-dev
If Magick++ is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a Magick++.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘magick’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4/magick’
Warning in install.packages :
installation of package ‘magick’ had non-zero exit status
* installing *source* package ‘rgl’ ...
** package ‘rgl’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for gcc... (cached) gcc -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 accepts -g... (cached) yes
checking for gcc -std=gnu99 option to accept ISO C89... (cached) none needed
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... no
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
* removing ‘/home/nick/R/x86_64-pc-linux-gnu-library/3.4/rgl’
Warning in install.packages :
installation of package ‘rgl’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp8fiUj6/downloaded_packages’

Error installing R package for Linux

Im trying to install a package named "rgeos" on R 3.3, but when I type
install.packages("rgeos")
But it returns me the following error (same happens with other packages, but not all the packages):
> * installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
configure: CC: gcc
configure: CXX: g++
configure: rgeos: 0.3-19
checking for /usr/bin/svnversion... no
configure: svn revision: 524
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/kdg/R/x86_64-pc-linux-gnu-library/3.3/rgeos’
>
> The downloaded source packages are in
> ‘/tmp/Rtmpsa5pDo/downloaded_packages’ Warning message: In
> install.packages("rgeos") : installation of package ‘rgeos’ had
> non-zero exit status
Any clues how con install this package?
It seems that when running R in Linux is necessary to install some build tools. As in this case, in the terminal:
sudo apt-get install libgeos-dev
Then try package install again.
hints from here
I solved it with the following:
cd /opt
git clone https://github.com/libgeos/geos
cd geos
export CC='clang' && export CXX='clang++' && export OBJC='clang'
./autogen.sh
./configure
make
sudo -EH make install
R
install.packages('rgeos')
NB: export clang is particular to me; I am just pasting my exact solution.

Unable to install rgdal and rgeos R libraries on Red hat linux

I have error while compiling rgdal adn rgoes package on our redhat linux machine. I tried to do some research but couldn't find a possible solution. Could you please help me with this as this is very important for me to solve.
**ERROR WHILE COMPILING RGDAL in R 3.0**
**strong text**
* installing *source* package ârgdalâ ...
** package ârgdalâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 0.8-10
checking for /usr/bin/svnversion... yes
configure: svn revision: 496
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1397: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from http://www.gdal.org/
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
--configure-args='--with-gdal-config=/usr/local/bin/gdal-config'
with appropriate values for your installation.
ERROR: configuration failed for package ârgdalâ
*****ERROR WHILE COMPILING RGEOS:*****
**strong text**
* installing *source* package ârgeosâ ...
** package ârgeosâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgeos: 0.2-17
checking for /usr/bin/svnversion... yes
configure: svn revision: 413M
checking geos-config usability... ./configure: line 1385: geos-config: command not found
no
configure: error: geos-config not usable
ERROR: configuration failed for package ârgeosâ
On fedora 20 you need to install geos and geos-devel !
sudo yum install geos geos-devel
After that the compilation in R work well!
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (gstat)
The downloaded source packages are in
‘/tmp/Rtmp9ciIzG/downloaded_packages’
I'm not on redhat (I'm on Ubuntu) so someone who is may be able to give better package names.. . But, when installing packages from source, you need the dev of the required libraries. In this case, you probably need to install:
libgdal1-dev
libgeos-dev
So:
yum install libgdal1 libgdal1-dev libgeos libgeos-dev
Then in R:
install.packages('gdal')
this is untested, since I don't want all the extra packages associated with those two!

Resources