'udunits' is a dependency I need to install but when I try to install via install.packages("udunits2") I get the error:
-----Error: libudunits2.a not found-----
If the udunits2 library is installed in a non-standard location,
use --configure-args='--with-udunits2-lib=/usr/local/lib' for example,
or --configure-args='--with-udunits2-include=/usr/include/udunits2'
replacing paths with appropriate values for your installation.
You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
environment variables.
If udunits2 is not installed, please install it.
It is required for this package.
I followed the solutions provided in Install udunits2 package for R3.3, but I still get the same issues.
I installed libudunits2-dev using sudo apt install libudunits2-dev and the package is installed as when I call dpkg -L libudunits2-dev I get:
/.
/usr
/usr/include
/usr/include/converter.h
/usr/include/udunits.h
/usr/include/udunits2.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libudunits2.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/udunits.pc
/usr/share
/usr/share/doc
/usr/share/doc/libudunits2-dev
/usr/share/doc/libudunits2-dev/ANNOUNCEMENT
/usr/share/doc/libudunits2-dev/BACKLOG
/usr/share/doc/libudunits2-dev/copyright
/usr/share/doc/libudunits2-dev/udunits2lib.html
/usr/share/doc/libudunits2-dev/udunits2lib.pdf.gz
/usr/share/info
/usr/share/info/udunits2lib.info.gz
/usr/lib/x86_64-linux-gnu/libudunits2.so
/usr/share/doc/libudunits2-dev/changelog.Debian.gz
Even when I install udunits2 via install.packages("udunits2", configure.args = '--with-udunits2-include=/usr/include/udunits2'), the same issue occurs.
Installing on Ubuntu 20.04.1
R 3.6.1 in anaconda environment.
Any help would be greatly appreciated.
Desire is to installed R {sf} and {RPostgres} packages on Ubuntu 18.04.4.
Trying:
R$> install.packages("sf")
configure: error: gdal-config not found or not executable.
Some SO searching (eg https://stackoverflow.com/a/49181048/2802810) suggests this:
sh$> sudo apt-get install libgdal-dev
The following packagess have unmet dependencies: libpq-dev :
Depends: libpq5 (= 10.12-0Ubuntu0.18.04.1) but 12.3-1.pgdg18.04+1 is
to be installed E: Unable to correct problems, you have broken
packages.
I also need libpq-dev for R {RPostgres}.
You may want to add PPA, depending on your R version.
https://launchpad.net/~marutter/+archive/ubuntu/c2d4u
https://launchpad.net/~marutter/+archive/ubuntu/c2d4u3.5
https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+
After adding PPA, you can install using sudo apt install r-cran-sf and sudo apt install r-cran-rpostgres
OKaaaay. The box I'm working in didn't have a Postgres repo installed (https://www.postgresql.org/download/linux/ubuntu/). Never libpq libs and that was all it needed.
I cannot install rgdal and rgeos on Databricks, any suggestions?
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/databricks/spark/R/lib/rgdal’
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/databricks/spark/R/lib/rgeos’
Here is one way to install rgdal and rgeos on R on Azure Databricks. Step 1 and 2 needs to be done each time you start the cluster. Step 1 can be automated (see below) but step 2 needs to be executed manually in a separate script or be added to the top of your R script.
Step 1
You need to first install gdal and geos on the linux machines in your cluster. This can be done with bash script in a databricks notebook. The %s is the magic command that allows this cell to run a shell script.
%sh
#!/bin/bash
#Start by updating everything
sudo apt-get update
##############
#### rgdal
#This installs gdal on the linux machine but not the R library (done in R script)
#See https://databricks.com/notebooks/rasterframes-notebook.html
sudo apt-get install -y gdal-bin libgdal-dev
#To be able to install the R library, you also need libproj-dev
#See https://philmikejones.me/tutorials/2014-07-14-installing-rgdal-in-r-on-linux/
sudo apt-get install -y libproj-dev
##############
#### rgeos
#This installs geos on the linux machine but not the R library (done in R script)
#See https://philmikejones.me/tutorials/2014-07-14-installing-rgdal-in-r-on-linux/
sudo apt install libgeos++dev
However, that is annoying to have to run manually each time, so you can create an init script that runs each time on startup of the cluster. So in a databricks python notebook, copy this code into a cell. Scripts in dbfs:/databricks/init/<name_of_cluster> will run on start-up for clusters with that name.
#This file creates a bash script called install_packages.sh. The cluster run this file on each startup.
# The bash script will be anything inside the variable script
clusterName = "RStudioCluster"
script = """#!/bin/bash
#Start by updating everything
sudo apt-get update
##############
#### rgdal
#This installs gdal on the linux machine but not the R library (done in R script)
#See https://databricks.com/notebooks/rasterframes-notebook.html
sudo apt-get install -y gdal-bin libgdal-dev
#To be able to install the R library, you also need libproj-dev
#See https://philmikejones.me/tutorials/2014-07-14-installing-rgdal-in-r-on-linux/
sudo apt-get install -y libproj-dev
##############
#### rgeos
#This installs geos on the linux machine but not the R library (done in R script)
#See https://philmikejones.me/tutorials/2014-07-14-installing-rgdal-in-r-on-linux/
sudo apt install libgeos++dev
"""
dbutils.fs.put("dbfs:/databricks/init/%s/install_packages.sh" % clusterName, script, True)
Step 2
So far you have just installed gdal and geos on the linux machines in the cluster. In this step you will install the R package rgdal. Recent versions of rgdal however, are not compatible with the most recent version of gdal available with apt-get. See here for more details and alternative ways to solve this, but if you are ok with an older version of rgdal then the easiest workaround is to install version 1.2-20 of rgdal. You do that in an databricks R notebook or in the Rstudio databricks app like this:
require(devtools)
install_version("rgdal", version="1.2-20")
install.packages("rgeos")
Setup done
Then you can import these libraries like usual:
library(rgdal)
library(rgeos)
I'm using R 3.3.2 and Ubuntu 16.10. I'm unable to install rgl and rgdal packages.
When I use
install.packages("rgl")
gives the following error message:
configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
When I use
install.packages("rgdal")
gives the following error message:
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
Edited
When I use
sudo apt-get install r-cran-rgl
in Ubuntu Terminal, it says
r-cran-rgl is already the newest version (0.95.1441-2)
However, the latest version of rgl is 0.96.0.
When I use
sudo apt-get install libgdal-dev libgeos++-dev
it throws the following error:
The following packages have unmet dependencies:
libgdal-dev : Depends: libopenjp2-7-dev but it is not going to be installed
I found a solution that was useful for me here: http://robinlovelace.net/r/2013/11/26/installing-rgdal-on-ubuntu.html.
In short, the solution would be this tree command lines:
sudo apt-get install aptitude # install aptitude as an alternative to apt-get
sudo aptitude install libgdal-dev # install the package (you may have to respond to queries here)
sudo aptitude install libproj-dev # install the proj.4 projection library
For rgl, just do sudo apt-get install r-cran-rgl.
For rgdal, follow the recommendation of the spatial folks eg here for sf and do this
add ubuntugis-unstable to the package repositories (e.g. with sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable and then sudo apt-get install libgdal-dev libgeos++-dev)
For general 'R on Ubuntu or Debian' questions, go to the r-sig-debian list.
Edit: Note that you don't need need ubuntugis-unstable repo if the current/older libgdal, libproj4 versions are good enough for you. Those are in the Ubuntu distro so just do sudo apt-get install ....
These installations worked for me provided that, in addition, I installed libxerces-c28. The need for the related shared object was indicated in the error log the first time I tried, after doing the installations indicated (libgdal, libgdal-dev, etc)
The issue here is not exactly how to plot maps through R, as I have found already a pretty nice example here, but rather how to make it work. In fact, I am unable to load library rgdal:
library(rgdal)
Error in library(rgdal) : there is no package called ‘rgdal’
However, when I try to install the above package manually, I get the following error:
....
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/eualin/R/i686-pc-linux-gnu-library/2.15/rgdal’
Warning in install.packages : installation of package ‘/home/eualin/Downloads/rgdal_0.8-5.tar.gz’ had non-zero exit status
Any input welcome!
I f you look at the package page on CRAN, you will see the following :
SystemRequirements: for building from source: GDAL >= 1.7.1 library
from http://trac.osgeo.org/gdal/wiki/DownloadSource and PROJ.4 (proj >= 4.4.9) from http://trac.osgeo.org/proj/; GDAL OSX frameworks built by William Kyngesburye at http://www.kyngchaos.com/ may be used for
source installs on OSX.
As you seem to be under Linux, you always build package from source, so you will have to install the corresponding libraries on your system. If you are under Mint, Ubuntu or another Debian derivative, you can do :
$ sudo apt-get install libgdal1-dev libproj-dev
One tip that can be useful, still under a Debian based system, is to install the apt-file package and run :
$ sudo apt-file update
Then, when you get an error such as :
configure: error: proj_api.h not found in standard or given locations.
You can use the following command to find which package you must install to get the missing file :
$ apt-file search proj_api.h
libproj-dev: /usr/include/proj_api.h
If you use OS X with the Homebrew package manager, and have R installed through the homebrew-science tap, you can install rgdal by first installing gdal.
brew install gdal
You may first want to list the options available before you run this in case you want something fancy like postgresql support. To see the available options type
brew options gdal
then to be fancy you can type
brew install --with-postgresql gdal
after a while you should be good to go with dependencies, since proj including your needed proj_api.h are dependencies! Unfortunately, rgdal still won't find pro_api.h right now since it isn't looking in /usr/local/include. To fix this and other possible maladies with your rgdal installation, use the following R command to install rgdal:
> install.packages('rgdal', type = "source", configure.args=c('--with-proj-include=/usr/local/include','--with-proj-lib=/usr/local/lib'))
This should be similar to what you would also need for MacPorts with the exception of the brew steps, and your libraries/headers are most likely under "/opt/local/lib" and "/opt/local/include" respectively.
Note: to brew upgraders if you are using "--with-armadillo" as an option with gdal, and upgraded armadillo to 7 from 6. You will have to recompile gdal before you upgrade/reinstall rgdal.
On a Fedora 21 system using R-3.2.0, the following worked:
yum install gdal.x86_64 gdal-devel.x86_64 gdal-libs.x86_64
yum install proj.x86_64 proj-devel.x86_64
yum install proj-epsg.x86_64 proj-nad.x86_64
Obviously this was the result of repeated tries to get:
install.packages("rgdal")
to work. You can probably do it all in one install.
On ubuntustudio 14.04 (same for all debian distros):
sudo apt-get install libproj-dev libgdal-dev
Then I could install package rgdal
R info:
R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Linux info:
Linux francois-K53SV 3.13.0-34-lowlatency #60-Ubuntu SMP PREEMPT Wed Aug 13 16:15:18 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Here what i did on Centos7:
yum install gdal gdal-devel
yum install proj-devel
yum install proj-nad
yum install proj-epsg
Then simply
install.packages("rgdal")
Worked fine but it wasn't clear at all.
In OSX, I download proj from http://www.kyngchaos.com/software/frameworks and I run the following command in R.
install.packages('rgdal', type = "source", configure.args=c('--with-proj-include=/Library/Frameworks/PROJ.framework/Headers', '--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'))
For ubuntu 16.04 and R 3.5.1, this works quite fast:
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev
Then;
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev
Finally in CRAN;
install.packages("rgdal")
This worked for me:
install.packages('rgdal',repos="http://www.stats.ox.ac.uk/pub/RWin")
For Mac (OS.X Version10.12.6) users, This worked for me.
First, go to command line and install gdal using >> brew install gdal
Second, got to Rstuduio(R console) and install the package using install.packages("rgdal")
For me (Ubuntu 16.04, R 3.4.2), a mixture of the above solutions worked:
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev
Then simply installed rgdal from CRAN.
The only thing that worked on my system was to compile PROJ4 from source as described here and then instal the rgdal package as
install.packages("rgdal")
For people in multi-user environments with multiple versions of proj installed (from source), the method I used was:
install.packages('rgdal',configure.args="--with-proj-include=/sw/proj/4.9.2/include --with-proj-lib=/sw/proj/4.9.2/lib")
To fix this you need to install libgdal-dev:
$ sudo apt install libgdal-dev
If anyone still has issues on this, I got a version of rgdal from this site :
https://cran.r-project.org/web/packages/rgdal/index.html
and installed it :
install.packages("filename.tar", repos = NULL, type = "source")
None of the above answers worked for me (running R 3.5.1 on Linux Mint 17.1). GDAL version in the Ubuntu repositories is 1.11.3, this causes installation of rGDAL to fail. Here is the solution that worked for me (from this website):
sudo apt-get install libexpat1-dev
Download and install GDAL
wget http://download.osgeo.org/gdal/2.1.1/gdal-2.1.1.tar.gz
tar xvf gdal-2.1.1.tar.gz
cd gdal-2.1.1
./configure
sudo make
sudo make install
Verify version
gdal-config --version
I then got this error:
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/rgdal/libs/rgdal.so':
libgdal.so.20: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
This was fixed by updating the bindings:
sudo ldconfig
Then running install.packages("rgdal") in R worked fine.
Unable to get rgdal to install properly, I have tried all mentioned and all suggestions here R not finding package even after package installation
library(rgdal)
rgdal: version: 1.4-3, (SVN revision 828)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
Path to GDAL shared files: C:/Users/xxx/Documents/R/win-library/3.4/rgdal/gdal
GDAL binary built with GEOS: TRUE
Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
Path to PROJ.4 shared files: C:/Users/xxx/Documents/R/win-library/3.4/rgdal/proj
Linking to sp version: 1.3-1
Warning message:
package ‘rgdal’ was built under R version 3.4.4
I have upgraded my R to 3.6.1
Try again:
batch_gdal_translate(x, desc, outsuffix = "4.img", of = "HFA", co="TILED=YES")
NULL
Warning messages:
1: In gdal_setInstallation() :
No GDAL installation found. Please install 'gdal' before continuing:
- www.gdal.org (no HDF4 support!)
- www.trac.osgeo.org/osgeo4w/ (with HDF4 support RECOMMENDED)
- www.fwtools.maptools.org (with HDF4 support)
2: In gdal_setInstallation() : If you think GDAL is installed, please run:
gdal_setInstallation(ignore.full_scan=FALSE)
i have tried to run this from Rstudio & command line R 3.6.1 GUI.
all times I have tried this I get positive results for the libraries being installed.
library(raster)
Loading required package: sp
library(rgdal)
rgdal: version: 1.4-4, (SVN revision 833)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
Path to GDAL shared files: C:/Users/xxx/Documents/R/R-3.6.1/library/rgdal/gdal
GDAL binary built with GEOS: TRUE
Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
Path to PROJ.4 shared files: C:/Users/xxx/Documents/R/R-3.6.1/library/rgdal/proj
Linking to sp version: 1.3-1
library(gdalUtils)
Registered S3 method overwritten by 'R.oo':
method from
throw.default R.methodsS3
the files I am trying to read are dted files?
x <- list.files(path = src, pattern = ".dt", full.names = TRUE)
length(x)
batch_gdal_translate(x, desc, outsuffix = "4.img", of = "HFA", co="TILED=YES")
I have tried the above with GTIFF .tif format also and I get the same error.
But I am not trying to read .hdf files, just .dt0, .dt1, .dt2
this will work on another machine that I have R installed on, however, I am trying to figure out what is wrong with the installation I have on "this" machine.
Explicitly adding the include path in CFLAGS worked for me
install.packages('rgdal', type = "source", configure.args=c('CFLAGS=-I/apps/proj4/5.2.0/include'))
If you are using MacPorts this should work:
Install gdal (proj6 will be installed as a dependency)
sudo port install gdal
Install pkg-config
sudo port install pkgconfig
Set PKG_CONIFG_PATH variable to point to a directory with proj.pc file. In my case this was:
export PKG_CONFIG_PATH=/opt/local/lib/proj6/lib/pkgconfig
If you are using Conda environment please use:
conda install -c conda-forge r-rgdal
conda install -c conda-forge/label/broken r-rgdal
conda install -c conda-forge/label/cf201901 r-rgdal
conda install -c conda-forge/label/cf202003 r-rgdal
conda install -c conda-forge proj