本地RedHat 6系统下安装R语言rgdal包的依赖配置求助
Got it, let's tackle this rgdal installation issue head-on. Since you're on a local Red Hat 6 server with no internet and limited repo access, we'll need to build all dependencies from source—starting with PROJ.4 and GDAL, then moving to rgdal itself. Here's the step-by-step process:
1. Install Required Compilation Tools First
Red Hat 6 needs basic build tools to compile source code. If these aren't already installed, you'll need to grab their RPMs from a trusted source (e.g., a connected machine with Red Hat 6 media) and transfer them to your server:
- Check for
gcc:gcc --version- If missing: Install with
rpm -ivh gcc-4.4.7-23.el6.x86_64.rpm(adjust version to match your system)
- If missing: Install with
- Check for
make:make --version- If missing: Install with
rpm -ivh make-3.81-23.el6.x86_64.rpm
- If missing: Install with
- Install
gcc-c++(required for some GDAL components):rpm -ivh gcc-c++-4.4.7-23.el6.x86_64.rpm
2. Build and Install PROJ.4 from Source
rgdal requires PROJ.4 (or newer PROJ versions) as a core dependency. We'll install it to a custom path to avoid conflicts with system packages:
- Download a compatible PROJ version (e.g., 6.2.1, which works with Red Hat 6 and later rgdal versions) from a connected machine, then transfer the
proj-6.2.1.tar.gzfile to your server. - Extract the source:
tar -xvf proj-6.2.1.tar.gz cd proj-6.2.1 - Configure the build (specify an install path like
/usr/local/proj):./configure --prefix=/usr/local/proj - Compile and install:
make && make install - Update your environment variables so the system can find PROJ:
echo 'export LD_LIBRARY_PATH=/usr/local/proj/lib:$LD_LIBRARY_PATH' >> ~/.bashrc echo 'export PATH=/usr/local/proj/bin:$PATH' >> ~/.bashrc source ~/.bashrc
3. Build and Install GDAL from Source
Next, install GDAL, which relies on the PROJ we just set up:
- Download a compatible GDAL version (e.g., 3.0.4, which pairs well with PROJ 6.2.1) as a
tar.gzfile, transfer it to your server. - Extract the source:
tar -xvf gdal-3.0.4.tar.gz cd gdal-3.0.4 - Configure the build, pointing it to our custom PROJ installation:
./configure --prefix=/usr/local/gdal --with-proj=/usr/local/proj - Compile and install:
make && make install - Update environment variables for GDAL:
echo 'export LD_LIBRARY_PATH=/usr/local/gdal/lib:$LD_LIBRARY_PATH' >> ~/.bashrc echo 'export PATH=/usr/local/gdal/bin:$PATH' >> ~/.bashrc source ~/.bashrc
4. Install rgdal from Source in R
Finally, we can install the rgdal R package using the dependencies we built:
- Download the rgdal source package (e.g.,
rgdal_1.5-28.tar.gz) from CRAN on a connected machine, transfer it to your server. - Launch R:
R - Run the installation command, specifying the paths to GDAL and PROJ:
install.packages("rgdal_1.5-28.tar.gz", type = "source", configure.args = c("--with-gdal=/usr/local/gdal", "--with-proj=/usr/local/proj", "--with-proj-lib=/usr/local/proj/lib", "--with-proj-include=/usr/local/proj/include")) - Verify the installation works:
If no errors pop up, you're good to go!library(rgdal)
内容的提问来源于stack exchange,提问作者Carole

