美文网首页
centos7 安装 gdal

centos7 安装 gdal

作者: dc的梦呓 | 来源:发表于2023-10-18 16:09 被阅读0次

安装gdal前需先安装proj6,安装proj6前需先安装sqlite3

1、下载安装 sqlite3

安装proj需要先安装sqlite3,

sqlite3:

https://www.sqlite.org/download.html 下载sqlite3 安装包
tar xvfz sqlite-autoconf-3430200.tar.gz
cd sqlite-autoconf-3430200

配置及编译安装

./configure --prefix=/usr/local/sqlite3 --enable-rtree=yes
make && make install

2、下载安装 proj6

wget https://download.osgeo.org/proj/proj-6.3.0.tar.gz
或者 https://github.com/OSGeo/PROJ/releases 手动选择下载

yum install gcc-c++ libstdc++-devel

设置环境变量:

export PKG_CONFIG_PATH=/usr/local/proj6
export SQLITE3_CFLAGS="-I/usr/local/sqlite3/include"
export SQLITE3_LIBS="-L/usr/local/sqlite3/lib -lsqlite3"
export PATH=/usr/local/sqlite3/bin/:$PATH
tar -xvf proj-6.3.0.tar.gz
cd proj-6.3.0
./configure --prefix=/usr/local/proj6
make && make install

make时,如果遇到错误:bits/c++config.h: No such file or directory

cd /usr/include/c++/4.8.2/
mkdir x86_64-redhat-linux   #若没有则创建目录
cp -R i686-redhat-linux/bits x86_64-redhat-linux/   #将i686-redhat-linux目录下的bits拷贝至x86_64-redhat-linux下

make时出现错误,修改后要先 make clean 后再 make

3、下载安装 gdal

https://gdal.org/download.html# 下载
or wget https://github.com/OSGeo/gdal/releases/download/v3.5.2/gdal-3.5.2.tar.gz

export PATH=/usr/local/proj6/bin:$PATH #设置环境变量

tar -xvf gdal-3.5.2.tar.gz
cd gdal-3.5.2
./configure --prefix=/usr/local/gdal3 --with-python=python3 --with-proj=/usr/local/proj6
make && make install

最后这步 make 耗时会比较久。
编译完成后,将 GDAL 添加到系统路径中:

echo 'export PATH=/usr/local/gdal3/bin:$PATH' >> ~/.bashrc && source ~/.bashrc

最后,查看是否安装成功:

gdalinfo --version
image.png

参考资料:
https://blog.csdn.net/gispipi/article/details/108140754
https://blog.csdn.net/CallmeAdo/article/details/106544465
https://gis.stackexchange.com/questions/317109/build-gdal-with-proj-version-6

相关文章

网友评论

      本文标题:centos7 安装 gdal

      本文链接:https://www.haomeiwen.com/subject/myrcidtx.html