Reputation: 3805
I want to install terra
package and other spatial packages (raster
,sf
) on databricks but running into below issues. On my databricks notebook, I do
install.packages("terra")
Based on the error message, the gdal is not configured. I am trying to find resources online that explains to me how to resolve it. I found this page but looks like there are so many solutions but don't know which one to use. Could anyone keep me like a step-to-step guide on how to configure rgdal on databricks and install spatial R packages.
Error: gdal-config not found while installing R dependent packages whereas gdal is installed
Upvotes: 1
Views: 2733
Reputation: 304
Have to install some missing clients and gdal using the following.
%sh
sudo rm -r /var/lib/apt/lists/*
sudo apt clean &&
sudo apt update --fix-missing -y &&
sudo apt install -y libmysqlclient21
sudo apt install -y gdal-bin
%sh
sudo apt --fix-missing -y update --fix-missing
sudo apt-get install -y libudunits2-dev libproj-dev libgeos-dev libgdal-dev
And then run install.packages(c("sf", "terra","raster"))
Upvotes: 0
Reputation: 3805
I ended up doing this. At this stage, I do not know why this works but running the below commands does the job. In the databricks notebook, I did this
%sh # this is to specify you want to run a shell command
sudo apt update
sudo apt-get install -y python3-dev
sudo apt-get install -y build-essential
sudo apt-get install -y mysql-client
sudo apt update
sudo apt-get update
sudo apt-get install -y libssl-dev
sudo apt-get install -y libssl1.1
sudo apt-get install --allow-downgrades -y libssl1.1=1.1.1f-1ubuntu2
sudo apt update
sudo apt-get install -y libmysqlclient-dev
sudo apt update
sudo apt-get update
sudo apt-get install -y libsqlite3-dev
sudo apt-get install -y gdal-bin
sudo apt-get install -y libgdal-dev
sudo apt-get install -y python3-gdal
gdal-config
Then on the next cell, I did this and it managed to install terra
%r
install.packages("terra")
Upvotes: 2
Reputation: 47491
That suggests that you do not have GDAL installed. You can have a look at the instructions for installing dependencies for terra and (overlapping, but with more detail) for sf.
In the comments you say that you are on a "windows machine", but that does not seem entirely accurate. It appears that "databricks" runs on Linux. That is, you are in a Linux environment (that you happens to access from a windows machine). But you may not have access to a terminal.
I do not know databricks, but perhaps this answer helps (it shows how to install GDAL on databricks)
Upvotes: 1