0

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")

enter image description here

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

89_Simple
  • 3,393
  • 3
  • 39
  • 94

2 Answers2

1

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)

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63
  • Okay. Thanks Robert. I am going to follow these instructions. I am not very familiar with linux environment but will try to follow the instructions. Thanks for the prompt response – 89_Simple Sep 28 '22 at 17:33
  • Thanks Robert. I did the below and it worked. Posting my solution in case someone else might use data bricks – 89_Simple Oct 09 '22 at 01:40
1

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")
89_Simple
  • 3,393
  • 3
  • 39
  • 94