一、准备工作
(经实践,在其他用户下存在某种问题,可能是对Centos系统上不熟悉,无法解决,需在root用户下安装):su - root
安装编译环境
sudo yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel
注意:如果嫌麻烦的话,那就直接yum groupinstall "Development tools”
yum -y groupinstall "Development tools"
yum -y install zlib-devel
二、安装GDAL
1、proj
tar -zxvf proj-6.1.0.tar.gz
cd proj-6.1.0
./configure --prefix=/usr/local
make
make install
cd ..
2、geos
bz2 解压支持安装:
sudo yum -y install bzip2
tar xjf geos-3.4.2.tar.bz2
cd geos-3.4.2
./configure --prefix=/usr/local
make
make install
ldconfig
cd ..
3、hdf4
tar -zxf hdf-4.2.13.tar.gz
cd hdf-4.2.13
./configure --prefix=/usr/local --enable-shared --disable-fortran --disable-netcdf
make
make install
cd ..
4、hdf5
tar -zxf hdf5-1.10.5.tar.gz
cd hdf5-1.10.5
export F9X=ifort
./configure --prefix=/usr/local --enable-cxx
make
make install
cd ..
5、gdal安装
tar -zxf gdal-3.1.4.tar.gz
cd gdal-3.1.4
make distclean
./configure --prefix=/usr/local --with-netcdf=no
make -j 8
make install
cd ..
6、生成python包
cd swig/python
#java使用 swgi/java make;make install
修改setup.cfg
vi setup.cfg
gdal_config=/usr/local/bin/gdal-config
python3 setup.py build
python3 setup.py install
输入pip list
可以看到gdal安装成功。
7、使用
python3
from osgeo import gdal
配置环境变量
(1) vim ~/.bashrc
(2)输入“i”进入插入模式,将光标移动到文件末尾
(3)
export PATH=$PATH:/usr/local/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
(4)按esc退出插入模式,输入“:wq”保存退出,执行“source ~/.bashrc”更新变量
(5)安装配置成功
linux 安装gdal(含hdf)记录
最新推荐文章于 2023-11-22 09:28:35 发布